Inital commit
This commit is contained in:
49
AddPinger.sh
Normal file
49
AddPinger.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/ash
|
||||
|
||||
###############################################################
|
||||
# @scriptname: AddPinger #
|
||||
# @description: #
|
||||
# Creates configuration and service files #
|
||||
# #
|
||||
# @project: SmartPinger #
|
||||
# @author: Bram Prieshof #
|
||||
###############################################################
|
||||
|
||||
#Goto ProjectRoot
|
||||
cd "$( dirname "$0" )"
|
||||
|
||||
#Request argument for type of new pinger
|
||||
case $1 in
|
||||
|
||||
-s|--smart)
|
||||
NewPingerType=Smart
|
||||
;;
|
||||
|
||||
-b|-bt|--bt|--bluetooth)
|
||||
NewPingerType=Bt
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Pinger type missing or incorrect."
|
||||
echo "Use '-s' or '--smart' for a smart pinger"
|
||||
echo "or use '-b', '--bt' or '--bluetooth' for a bluetooth pinger."
|
||||
exit 10
|
||||
;;
|
||||
esac
|
||||
|
||||
#Ask for name for new pinger
|
||||
read -p "Enter name of pinger to be added: " NewPingerName
|
||||
|
||||
#Create service file
|
||||
cp ./templates/"$NewPingerType"Ping.service.template /etc/init.d/$NewPingerType'Ping'$NewPingerName
|
||||
chmod +x /etc/init.d/$NewPingerType'Ping'$NewPingerName
|
||||
sed -i -e "/PingerName=/c\PingerName=$NewPingerName" /etc/init.d/$NewPingerType'Ping'$NewPingerName
|
||||
|
||||
#Create config file
|
||||
cp ./templates/"$NewPingerType"Ping.cfg.template ./config/$NewPingerType'Ping_'$NewPingerName.cfg
|
||||
|
||||
#Instructions
|
||||
echo "Before stating pinger edit the following config $(pwd)/config/"$NewPingerType"Ping_"$NewPingerName".cfg"
|
||||
echo "Start pinger using 'service "$NewPingerType'Ping'$NewPingerName" start'"
|
||||
echo "Enable pinger on boot using 'rc-update add "$NewPingerType'Ping'$NewPingerName" '"
|
||||
echo "also don't forget 'lbu commit'"
|
||||
Reference in New Issue
Block a user