rc script, pm - package manger and update init scripts

This commit is contained in:
wt committed 2024-07-08 18:40:50 +07:00
1 parent 7c88b136ef
commit 31717c44b6
40 files changed
+569 -231

No files matched your search

+6 -14
View File
@@ -3,29 +3,21 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting dnsd "
notify "Starting dnsd "
# sleep 10
/usr/bin/dnsd -d -c /etc/dnsd.conf
echo "nameserver 0.0.0.0" > /etc/resolv.conf
if [[ "$?" == "0" ]]; then
echo "nameserver 0.0.0.0" > /etc/resolv.conf
echo $(pgrep dnsd) > /var/run/dnsd.pid
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "Stopping dnsd "
notify "Stopping dnsd "
kill $(cat /var/run/dnsd.pid) &> /dev/null
rm /var/run/dnsd.pid
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+7 -14
View File
@@ -3,31 +3,24 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting dnsmasq "
notify "Starting dnsmasq "
sleep 1
/usr/bin/dnsmasq --user=dnsmasq --pid-file=/var/run/dnsmasq.pid
echo "nameserver 0.0.0.0" > /etc/resolv.conf
if [[ "$?" == "0" ]]; then
echo "nameserver 0.0.0.0" > /etc/resolv.conf
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "\nStopping dnsmasq "
notify "\nStopping dnsmasq "
if [ -f /var/run/dnsmasq.pid ]; then
kill $(cat /var/run/dnsmasq.pid) &> /dev/null
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
rm /var/run/dnsmasq &> /dev/null
else
printf "[$Red Dnsmasq is not running $Color_off]\n"
notify "[$Red Dnsmasq is not running $Color_off]\n"
fi
;;
restart|reload)
+6 -12
View File
@@ -3,27 +3,21 @@ Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting fptd "
notify "Starting fptd "
tcpsvd -vE 0.0.0.0 21 ftpd -w -S -A $(cat /etc/openrouter/ftppath) &>/dev/null &
echo $! > /var/run/ftpd.pid
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Cpolor_Off]\n"
fi
check $?
;;
stop)
printf "Stopping ftpd "
notify "Stopping ftpd "
kill $(cat /var/run/ftpd.pid)
killall ftpd
rm /var/run/ftpd.pid
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Color_Off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+4 -6
View File
@@ -4,15 +4,13 @@ Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Setting up hostname "
notify "Setting up hostname "
/bin/hostname -F /etc/hostname
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Color_Off]\n"
fi
check $?
;;
stop)
;;
+6 -12
View File
@@ -3,26 +3,20 @@ Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting httpd "
notify "Starting httpd "
httpd -h /srv/www &> /dev/null
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Cpolor_Off]\n"
fi
check $?
;;
stop)
printf "Stopping httpd "
notify "Stopping httpd "
killall httpd
#kill $(cat /var/run/httpd.pid)
#rm /var/run/httpd.pid
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Color_Off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+15
View File
@@ -1,4 +1,7 @@
#!/bin/sh
Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
init () {
test -f $DAEMON || exit 0
@@ -58,3 +61,15 @@ sleep 1
return 1
}
check() {
if [[ "$1" == "0" ]];then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Cpolor_Off]\n"
fi
}
notify() {
printf "$*"
}
+8 -14
View File
@@ -8,27 +8,21 @@ DAEMON="iptables"
IPTABLES_ARGS=""
. /etc/init.d/init-functions
start() {
printf 'Starting %s: ' "$DAEMON"
notify "Starting $DAEMON"
iptables-restore /etc/iptables.conf
status=$?
if [ "$status" -eq 0 ]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
return "$status"
}
stop() {
printf 'Stopping %s: ' "$DAEMON"
notify "Stopping $DAEMON"
iptables -F
status=$?
if [ "$status" -eq 0 ]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
return "$status"
}
@@ -39,11 +33,11 @@ restart() {
}
save() {
printf 'Saving %s: ' "$DAEMON"
notify 'Saving %s: ' "$DAEMON"
iptables-save -f /etc/iptables.conf
status=$?
if [ "$status" -eq 0 ]; then
printf "[$Green OK $Color_off]\n"
notify "[$Green OK $Color_off]\n"
else
echo "SKIP (read-only file system detected)"
fi
+7 -13
View File
@@ -3,28 +3,22 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting klogd "
notify "Starting klogd "
klogd
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "Stopping klogd "
notify "Stopping klogd "
if [ -f /var/run/klogd.pid ]; then
kill $(cat /var/run/klogd.pid)
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
rm /var/run/klogd.pid &> /dev/null
else
printf "[$Red Klogd is not running $Color_off]\n"
notify "[$Red Klogd is not running $Color_off]\n"
fi
;;
restart|reload)
+6 -12
View File
@@ -3,26 +3,20 @@ Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting networking "
notify "Starting networking "
/usr/bin/ifup -a &>/dev/null &
echo $! > /var/run/networking.pid
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Cpolor_Off]\n"
fi
check $?
;;
stop)
printf "Stopping networking "
notify "Stopping networking "
/usr/bin/ifdown -a
rm /var/run/networking.pid
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Color_Off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+6 -12
View File
@@ -3,24 +3,18 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting nginx "
notify "Starting nginx "
nginx
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "Stopping nginx "
notify "Stopping nginx "
nginx -s stop
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+6 -12
View File
@@ -3,26 +3,20 @@ Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting openrouter software "
notify "Starting openrouter software "
cd /srv/ftpd/auth_service_router/bin && ./auth_service &> /dev/null &
cd /srv/ftpd/openrouter_adminpanel/bin && ./openrouter &> /dev/null &
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Cpolor_Off]\n"
fi
check $?
;;
stop)
printf "Stopping openrouter software "
notify "Stopping openrouter software "
killall openrouter
killall auth_service
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Color_Off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+6 -12
View File
@@ -3,24 +3,18 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting sshd "
notify "Starting sshd "
/usr/bin/sshd -D &
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "Stopping sshd "
notify "Stopping sshd "
killall sshd
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+6 -12
View File
@@ -3,24 +3,18 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Configuring swap "
notify "Configuring swap "
swapon -a
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "Stopping use swap "
notify "Stopping use swap "
swapoff -a
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
restart|reload)
"$0" stop
+4 -6
View File
@@ -4,15 +4,13 @@ Green='\033[0;32m'
Color_Off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Setting up sysctl "
notify "Setting up sysctl "
sysctl -p &> /dev/null
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_Off]\n"
else
printf "[$Red ERR $Color_Off]\n"
fi
check $?
;;
stop)
;;
+7 -13
View File
@@ -3,28 +3,22 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting syslogd "
notify "Starting syslogd "
syslogd
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "Stopping syslogd "
notify "Stopping syslogd "
if [ -f /var/run/syslogd.pid ]; then
kill $(cat /var/run/syslogd.pid)
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
rm /var/run/syslogd.pid &> /dev/null
else
printf "[$Red Syslogd is not running $Color_off]\n"
notify "[$Red Syslogd is not running $Color_off]\n"
fi
;;
restart|reload)
+6 -12
View File
@@ -3,24 +3,18 @@ Green='\033[0;32m'
Color_off='\033[0m'
Red='\033[0;31m'
. /etc/init.d/init-functions
case "$1" in
start)
printf "Starting telnet "
notify "Starting telnet "
telnetd -p $(cat /etc/openrouter/telnet/port)
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
stop)
printf "Stopping telnet "
notify "Stopping telnet "
killall telnetd
if [[ "$?" == "0" ]]; then
printf "[$Green OK $Color_off]\n"
else
printf "[$Red ERR $Color_off]\n"
fi
check $?
;;
restart|reload)
"$0" stop