-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add reading of environment and rsync to the tftp server
- Loading branch information
Showing
8 changed files
with
206 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
{% for name,value in env_vars.items() -%} | ||
export {{ name }}={{ value }} | ||
{% endfor -%} | ||
export IOC_GROUP={{ ioc_group }} | ||
export IOC_NAME={{ ioc_name }} | ||
export IOC_PATH={{ ioc_path }} | ||
|
||
pkill -f rsync-background &>/dev/null | ||
|
||
ibek dev instance $IOC_PATH | ||
|
||
mkdir -p $RTEMS_TFTP_PATH | ||
cd $RTEMS_TFTP_PATH | ||
|
||
# get previous contents | ||
rsync -rt "rsync://$RTEMS_TFTP_IP:12002/files/$IOC_GROUP/$IOC_NAME/" $RTEMS_TFTP_PATH 2>/dev/null | ||
|
||
echo " | ||
#!/bin/bash | ||
while true; do | ||
inotifywait -e modify,create,delete,move -r $RTEMS_TFTP_PATH | ||
rsync -rt --delete /$RTEMS_TFTP_PATH/ \ | ||
"rsync://$RTEMS_TFTP_IP:12002/files/$IOC_GROUP/$IOC_NAME/" &> /tmp/rsync.log | ||
done | ||
" > /tmp/rsync-background.sh | ||
|
||
nohup bash /tmp/rsync-background.sh &> /tmp/rsync-background.log & | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import subprocess | ||
from typing import Union | ||
|
||
import typer | ||
|
||
|
||
def run_command( | ||
command: str, interactive=True, error_OK=False, show=False | ||
) -> Union[str, bool]: | ||
""" | ||
Run a command and return the output | ||
if interactive is true then allow stdin and stdout, return the return code, | ||
otherwise return True for success and False for failure | ||
args: | ||
command: the command to run | ||
interactive: if True then allow stdin and stdout | ||
error_OK: if True then do not raise an exception on failure | ||
show: typer.echo the command output to the console | ||
""" | ||
|
||
p_result = subprocess.run(command, capture_output=not interactive, shell=True) | ||
|
||
if interactive: | ||
output = error_out = "" | ||
else: | ||
output = p_result.stdout.decode() | ||
error_out = p_result.stderr.decode() | ||
|
||
if interactive: | ||
result: Union[str, bool] = p_result.returncode == 0 | ||
else: | ||
result = output + error_out | ||
|
||
if p_result.returncode != 0 and not error_OK: | ||
typer.echo("\nCommand Failed:") | ||
if not globals.EC_VERBOSE: | ||
typer.echo(command) | ||
typer.echo(output) | ||
typer.echo(error_out) | ||
raise typer.Exit(1) | ||
|
||
if show: | ||
typer.echo(output) | ||
typer.echo(error_out) | ||
|
||
return result |