Skip to content

Commit

Permalink
added parsing script
Browse files Browse the repository at this point in the history
  • Loading branch information
jnau committed May 21, 2020
1 parent 42b0d41 commit 6a4efcf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cloud-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ runcmd:

- cd /home/ubuntu
- nohup /opt/encoded/checkfiles/script $(cat /opt/checkfiles_args.txt) 2> errors_prod.log 1> output_prod.log &

- echo "$(cut -d " " -f 1-6 /opt/checkfiles_args.txt) https://test.encodedcc.org" > /opt/test_args.txt
- nohup /opt/encoded/checkfiles/writeTestArgs $(cat /opt/checkfiles_args.txt | rev | cut -d " " -f 2- | rev) > /opt/test_args.txt
- nohup /opt/encoded/checkfiles/script $(cat /opt/test_args.txt) 2> errors_test.log 1> output_test.log &

users:
Expand Down Expand Up @@ -100,5 +99,6 @@ write_files:
permissions: 0755
content: |
#!/bin/sh -e
cd /home/ubuntu; nohup /opt/encoded/checkfiles/script %(ARGS)s 2> errors_prod.log 1> output_prod.log &; nohup /opt/encoded/checkfiles/script $(cat /opt/test_args.txt) 2> errors_test.log 1> output_test.log &;
cd /home/ubuntu; nohup /opt/encoded/checkfiles/script %(ARGS)s 2> errors_prod.log 1> output_prod.log &
nohup /opt/encoded/checkfiles/script $(cat /opt/test_args.txt) 2> errors_test.log 1> output_test.log &
exit 0
26 changes: 26 additions & 0 deletions writeTestArgs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
EXTRA=() # array to hold extra positional arguments
while [[ $# -gt 0 ]] # number of arguments needs to be greater than 0
do
key="$1"
case $key in
--username)
USERNAME="$2"
shift 2 # pass username and value
;;
--password)
PASSWORD="$2"
shift 2 # pass password and value
;;
--bot-token)
BOT="$2"
shift 2 # pass bot-token and value
;;
*) # unnecessary option
EXTRA+=("$1") # save it in an array to allow completion of script
shift # pass anything not specified, default: 1
;;
esac
done
set -- "${EXTRA[@]}" # restore positional parameters to allow rest of script to run without the extra options
echo "--username ${USERNAME} --password ${PASSWORD} --bot-token ${BOT} https://test.encodedcc.org/"

0 comments on commit 6a4efcf

Please sign in to comment.