Skip to content

Commit

Permalink
update to use systemctl
Browse files Browse the repository at this point in the history
  • Loading branch information
TrystanLea committed Jan 3, 2021
1 parent 5fb197c commit e58dd8f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions emoncms-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fi

#-----------------------------------------------------------------------------------------------

sudo service feedwriter stop
sudo systemctl stop feedwriter

# Get MYSQL authentication details from settings.php
if [ -f /home/pi/backup/get_emoncms_mysql_auth.php ]; then
Expand Down Expand Up @@ -85,7 +85,7 @@ cp /home/pi/data/node-red/settings.js $backup_location
cp --verbose -r /home/pi/data/phpfina/. $backup_location/phpfina
cp --verbose -r /home/pi/data/phptimeseries/. $backup_location/phptimeseries

sudo service feedwriter start > /dev/null
sudo systemctl start feedwriter > /dev/null

date
echo "=== Emoncms export complete! ===" # This string is identified in the interface to stop ongoing AJAX calls, please ammend in interface if changed here
14 changes: 7 additions & 7 deletions emoncms-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ then
else
echo "ERROR: Backup $script_location/backup/config.cfg file does not exist"
exit 1
sudo service feedwriter start > /dev/null
sudo systemctl start feedwriter > /dev/null
fi

module_location="${emoncms_location}/Modules/backup"
Expand Down Expand Up @@ -60,7 +60,7 @@ fi
#-----------------------------------------------------------------------------------------------

# Disabled in @borphin commit?
sudo service feedwriter stop
sudo systemctl stop feedwriter

# Get MYSQL authentication details from settings.php
if [ -f $script_location/get_emoncms_mysql_auth.php ]; then
Expand All @@ -69,7 +69,7 @@ if [ -f $script_location/get_emoncms_mysql_auth.php ]; then
else
echo "Error: cannot read MYSQL authentication details from Emoncms $script_location/get_emoncms_mysql_auth.php php & settings.php"
echo "$PWD"
sudo service feedwriter start > /dev/null
sudo systemctl start feedwriter > /dev/null
exit 1
fi

Expand All @@ -79,12 +79,12 @@ if [ -n "$username" ]; then # if username string is not empty
if [ $? -ne 0 ]; then
echo "Error: failed to export mysql data"
echo "emoncms export failed"
sudo service feedwriter start > /dev/null
sudo systemctl start feedwriter > /dev/null
exit 1
fi
else
echo "Error: Cannot read MYSQL authentication details from Emoncms settings.php"
sudo service feedwriter start > /dev/null
sudo systemctl start feedwriter > /dev/null
exit 1
fi

Expand Down Expand Up @@ -160,11 +160,11 @@ gzip -fv $backup_location/emoncms-backup-$date.tar 2>&1
if [ $? -ne 0 ]; then
echo "Error: failed to compress tar file"
echo "emoncms export failed"
sudo service feedwriter start > /dev/null
sudo systemctl start feedwriter > /dev/null
exit 1
fi

sudo service feedwriter start > /dev/null
sudo systemctl start feedwriter > /dev/null

echo "Backup saved: $backup_location/emoncms-backup-$date.tar.gz"
date
Expand Down
18 changes: 9 additions & 9 deletions emoncms-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ then # if username sring is not empty
if [ -f $backup_location/import/emoncms.sql ]; then
echo "Stopping services.."
if [[ $emonhub == "loaded" ]]; then
sudo service emonhub stop
sudo systemctl stop emonhub
fi
if [[ $feedwriter == "loaded" ]]; then
sudo service feedwriter stop
sudo systemctl stop feedwriter
fi
if [[ $mqtt_input == "loaded" ]]; then
sudo service mqtt_input stop
sudo systemctl stop mqtt_input
fi
if [[ $emoncms_mqtt == "loaded" ]]; then
sudo service emoncms_mqtt stop
sudo systemctl stop emoncms_mqtt
fi
echo "Emoncms MYSQL database import..."
mysql -u$username -p$password $database < $backup_location/import/emoncms.sql
Expand Down Expand Up @@ -175,22 +175,22 @@ fi
# Restart services
if [[ $emonhub == "loaded" ]]; then
echo "Restarting emonhub..."
sudo service emonhub start
sudo systemctl start emonhub
fi
if [[ $feedwriter == "loaded" ]]; then
echo "Restarting feedwriter..."
sudo service feedwriter start
sudo systemctl start feedwriter
fi
if [[ $mqtt_input == "loaded" ]]; then
echo "Restarting mqtt_input..."
sudo service mqtt_input start
sudo systemctl start mqtt_input
fi
if [[ $emoncms_mqtt == "loaded" ]]; then
echo "Restarting emoncms_mqtt..."
sudo service emoncms_mqtt start
sudo systemctl start emoncms_mqtt
fi
date +"%Y-%m-%d-%T"
# This string is identified in the interface to stop ongoing AJAX calls in logger window, please ammend in interface if changed here
echo "=== Emoncms import complete! ==="
sudo service apache2 restart
sudo systemctl restart apache2
12 changes: 6 additions & 6 deletions usb-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ echo
# ---------------------------------------------------
echo "Stopping services.."
if [[ $emonhub == "loaded" ]]; then
sudo service emonhub stop
sudo systemctl stop emonhub
fi
if [[ $feedwriter == "loaded" ]]; then
sudo service feedwriter stop
sudo systemctl stop feedwriter
fi
if [[ $emoncms_mqtt == "loaded" ]]; then
sudo service emoncms_mqtt stop
sudo systemctl stop emoncms_mqtt
fi

# ---------------------------------------------------------------
Expand Down Expand Up @@ -233,15 +233,15 @@ redis-cli "flushall" 2>&1
# Restart services
if [[ $emonhub == "loaded" ]]; then
echo "Restarting emonhub..."
sudo service emonhub start
sudo systemctl start emonhub
fi
if [[ $feedwriter == "loaded" ]]; then
echo "Restarting feedwriter..."
sudo service feedwriter start
sudo systemctl start feedwriter
fi
if [[ $emoncms_mqtt == "loaded" ]]; then
echo "Restarting emoncms MQTT..."
sudo service emoncms_mqtt start
sudo systemctl start emoncms_mqtt
fi

# ---------------------------------------------------
Expand Down

0 comments on commit e58dd8f

Please sign in to comment.