add service scripts

This commit is contained in:
Viktor Markstädter
2022-03-30 13:16:57 +02:00
parent fec9a20f1b
commit ce71a8adbc
4 changed files with 45 additions and 0 deletions

28
install.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SERVICE_NAME=$(basename $SCRIPT_DIR)
# set permissions for script files
chmod a+x $SCRIPT_DIR/restart.sh
chmod 744 $SCRIPT_DIR/restart.sh
chmod a+x $SCRIPT_DIR/uninstall.sh
chmod 744 $SCRIPT_DIR/uninstall.sh
chmod a+x $SCRIPT_DIR/service/run
chmod 755 $SCRIPT_DIR/service/run
# create sym-link to run script in deamon
ln -s $SCRIPT_DIR/service /service/$SERVICE_NAME
# add install-script to rc.local to be ready for firmware update
filename=/data/rc.local
if [ ! -f $filename ]
then
touch $filename
chmod 755 $filename
echo "#!/bin/bash" >> $filename
echo >> $filename
fi
grep -qxF "$SCRIPT_DIR/install.sh" $filename || echo "$SCRIPT_DIR/install.sh" >> $filename

4
restart.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
kill $(pgrep -f "python $SCRIPT_DIR/dbus-goecharger-acload.py")

5
service/run Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
exec 2>&1
python $(realpath $SCRIPT_DIR/../dbus-goecharger-acload.py)

8
uninstall.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SERVICE_NAME=$(basename $SCRIPT_DIR)
rm /service/$SERVICE_NAME
kill $(pgrep -f 'supervise dbus-goecharger-acload')
chmod a-x $SCRIPT_DIR/service/run
./restart.sh