Add variables in bash script.

This commit is contained in:
Florian
2018-05-27 22:34:15 +02:00
parent 72a5b01ae9
commit 8a21156042

View File

@@ -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