diff --git a/src/main/bash/codiki.bash b/src/main/bash/codiki.bash index aaf9e24..eb39a25 100755 --- a/src/main/bash/codiki.bash +++ b/src/main/bash/codiki.bash @@ -1,16 +1,17 @@ #!/bin/bash +workspace='/opt/codiki' codikiScreenName='codiki' -lockFile='/opt/codiki/bin/lock' -deadFile='/opt/codiki/bin/dead' +lockFile='/bin/lock' +deadFile='/bin/dead' screenRegex='codiki.\(([0-9]{2}/){2}[0-9]{4} [0-9]{2}(:[0-9]{2}){2}\)' start() { - screen -dmS $codikiScreenName java -jar /opt/codiki/bin/codiki.jar + screen -dmS $codikiScreenName java -jar $workspace/bin/codiki.jar if [ $? -eq 0 ] then - date > $lockFile - rm -f $deadFile + date > $workspace$lockFile + rm -f $workspace$deadFile else echo "Service failed to start..." exit 1 @@ -18,13 +19,13 @@ start() { } stop() { - if [ $(status_by_screen) -eq 1 ] && [ -f $lockFile ] + if [ $(status_by_screen) -eq 1 ] && [ -f $workspace$lockFile ] then screen -dr $codikiScreenName -X -S quit if [ $? -eq 0 ] then - rm -f $lockFile - date > $deadFile + rm -f $workspace$lockFile + date > $workspace$deadFile else echo "Service failed to stop..." exit 1 @@ -35,22 +36,24 @@ stop() { } status() { - if [ -f $lockFile ] && [ $(status_by_screen) -eq 1 ] + if [ -f $workspace$lockFile ] && [ $(status_by_screen) -eq 1 ] then tput setaf 2; cat << EOF codiki.service - The Codiki web app server Active: active (running) since $(cat $lockFile) EOF + echo '' else tput setaf 1; cat << EOF codiki.service - The Codiki web app server Active: inactive (dead) since $(cat $deadFile) EOF + echo '' fi } restart() { - if [ -f $lockFile ] + if [ -f $workspace$lockFile ] then stop fi