make install.sh more pretty
This commit is contained in:
19
install.sh
19
install.sh
@@ -145,16 +145,23 @@ set_cron(){
|
|||||||
|
|
||||||
set_service(){
|
set_service(){
|
||||||
printm "Setting systemd service"
|
printm "Setting systemd service"
|
||||||
printf "How often do you want the script to run in seconds? (default is 120): "
|
printf "How often do you want the script to run in seconds? (default is 120): "
|
||||||
read MIN
|
read MIN
|
||||||
if [ -z "$MIN" ]; then
|
if [ -z "$MIN" ]; then
|
||||||
MIN=120
|
MIN=120
|
||||||
fi
|
fi
|
||||||
sed -i "s/120/${MIN}/" src/config.py
|
sed -i "s/120/${MIN}/" src/config.py
|
||||||
cwd=$(pwd)
|
cwd=$(pwd)
|
||||||
user=$(whoami)
|
user=$(whoami)
|
||||||
exec_start="${python} ${cwd}/src/rpi-cpu2mqtt.py --service"
|
exec_start="${python} ${cwd}/src/rpi-cpu2mqtt.py --service"
|
||||||
|
if [ -f /etc/systemd/system/rpi-mqtt-monitor.service ]; then
|
||||||
|
read -p "Service file already exists. Do you want to remove it? (y/n) " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]* ) sudo rm /etc/systemd/system/rpi-mqtt-monitor.service; break;;
|
||||||
|
[Nn]* ) return;;
|
||||||
|
* ) echo "Please answer y for yes or n for no.";;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
print_green "+ Copy rpi-mqtt-monitor.service to /etc/systemd/system/"
|
print_green "+ Copy rpi-mqtt-monitor.service to /etc/systemd/system/"
|
||||||
sudo cp ${cwd}/rpi-mqtt-monitor.service /etc/systemd/system/
|
sudo cp ${cwd}/rpi-mqtt-monitor.service /etc/systemd/system/
|
||||||
sudo sed -i "s|WorkingDirectory=.*|WorkingDirectory=${cwd}|" /etc/systemd/system/rpi-mqtt-monitor.service
|
sudo sed -i "s|WorkingDirectory=.*|WorkingDirectory=${cwd}|" /etc/systemd/system/rpi-mqtt-monitor.service
|
||||||
|
|||||||
Reference in New Issue
Block a user