43 lines
1.1 KiB
Bash
Executable File
43 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Install script for NBMrec daemon
|
|
# by Samuel ORTION
|
|
|
|
install()
|
|
{
|
|
START_TIME="22:00" # default start time
|
|
sudo cp ./src/nbmrec.sh /usr/local/bin/nbmrec.sh
|
|
sudo cp ./conf/nbmrec.service /etc/systemd/system/nbmrec.service
|
|
sudo cp ./conf/nbmrec.timer /etc/systemd/system/nbmrec.timer
|
|
sudo mkdir -p /usr/local/etc/nbmrec/
|
|
sudo cp ./conf/nbmrec.conf /usr/local/etc/nbmrec/nbmrec.conf
|
|
|
|
if [ -f /usr/local/etc/nbmrec/nbmrec.conf ]; then
|
|
source /usr/local/etc/nbmrec/nbmrec.conf
|
|
fi
|
|
|
|
sudo sed -i "s/<USER>/$USER/g" /etc/systemd/system/nbmrec.service
|
|
sudo sed -i "s/<start_time>/$START_TIME/g" /etc/systemd/system/nbmrec.timer
|
|
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now nbmrec.timer
|
|
}
|
|
|
|
uninstall()
|
|
{
|
|
sudo systemctl disable --now nbmrec.timer
|
|
sudo rm -rf /usr/local/bin/nbmrec.sh
|
|
sudo rm -rf /etc/systemd/system/nbmrec.service /etc/systemd/system/nbmrec.timer
|
|
sudo rm -rf /usr/local/etc/nbmrec/
|
|
sudo systemctl daemon-reload
|
|
}
|
|
|
|
# Check if --uninstall is specified
|
|
if [ "$1" == "--uninstall" ]; then
|
|
uninstall
|
|
exit 0
|
|
else
|
|
install
|
|
exit 0
|
|
fi
|