update scripts

This commit is contained in:
wt
2024-11-01 14:15:42 +07:00
parent 95e2551110
commit 4a8ea1b190
17 changed files with 381 additions and 126 deletions
+13 -1
View File
@@ -35,13 +35,19 @@ rc() {
#--- restart function ---
restart() {
$0 stop
sleep 1
$0 start
}
reload() {
restart
}
#------------------------
#--- help function ---
help() {
echo "$0 init script usage: $0 {start|stop|restart|reload}"
echo "$0 init script usage: $0 {start|stop|restart|reload|help}"
exit 1
}
#---------------------
@@ -54,3 +60,9 @@ check() {
printf "$BBLUE**$BGREEN SUCCESS: $2\n$RESET"
}
#-----------------------------------------------
#--- notify func ---
notify() {
printf "$BBLUE**$BYELLOW $1\n$RESET"
}
#-------------------
+18 -14
View File
@@ -5,21 +5,25 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting dnsd"
/usr/bin/dnsd -d -c /etc/dnsd.conf
check $? "start dnsd"
echo $(pgrep dnsd) > /var/run/dnsd.pid
return $?
}
stop() {
notify "Stopping dnsd"
kill $(cat /var/run/dnsd.pid)
check $? "stop dnsd"
rm /var/run/dnsd.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting dnsd\n$RESET"
/usr/bin/dnsd -d -c /etc/dnsd.conf
check $? "start dnsd"
echo $(pgrep dnsd) > /var/run/dnsd.pid
;;
stop)
printf "$BBLUE**$BYELLOW Stopping dnsd\n$RESET"
kill $(cat /var/run/dnsd.pid)
check $? "stop dnsd"
rm /var/run/dnsd.pid
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+17 -13
View File
@@ -5,20 +5,24 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting dnsmasq"
/usr/bin/dnsmasq --user=dnsmasq --pid-file=/var/run/dnsmasq.pid
check $? "start dnsmasq"
return $?
}
stop() {
notify "Stopping dnsmasq"
kill $(cat /var/run/dnsmasq.pid)
check $? "stop dnsmasq"
rm /var/run/dnsmasq.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting dnsmasq\n$RESET"
/usr/bin/dnsmasq --user=dnsmasq --pid-file=/var/run/dnsmasq.pid
check $? "start dnsmasq"
;;
stop)
printf "$BBLUE**$BYELLOW Stopping dnsmasq\n$RESET"
kill $(cat /var/run/dnsmasq.pid)
check $? "stop dnsmasq"
rm /var/run/dnsmasq.pid &> /dev/null
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+18 -14
View File
@@ -5,21 +5,25 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting ftpd"
tcpsvd -vE 0.0.0.0 21 ftpd -w -S -A /srv/ftpd &>/dev/null &
check $? "start ftpd"
echo $(pgrep tcpsvd) > /ar/run/ftpd.pid
return $?
}
stop() {
notify "Stopping ftpd"
kill $(cat /var/run/ftpd.pid)
check $? "stop ftpd"
rm /var/run/ftpd.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting ftpd\n$RESET"
tcpsvd -vE 0.0.0.0 21 ftpd -w -S -A /srv/ftpd &>/dev/null &
check $? "start ftpd"
echo $(pgrep tcpsvd) > /ar/run/ftpd.pid
;;
stop)
printf "$BBLUE**$BYELLOW Stopping ftpd\n$RESET"
kill $(cat /var/run/ftpd.pid)
check $? "stop ftpd"
rm /var/run/ftpd.pid
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting hostapd"
if [ "$2" = "" ]; then
/usr/bin/hostapd -P /var/run/hostapd.pid /etc/hostapd/hostapd
check $? "start hostapd"
else
/usr/bin/hostapd -P /var/run/hostapd.pid $2
check $? "start hostapd"
fi
return $?
}
stop() {
notify "Stopping hostapd"
if [ ! -f /var/run/hostapd.pid ]; then
notify "$RESET[$RED Dnsmasq is not running $RESET]"
exit 1
fi
kill $(cat /var/run/hostapd.pid)
check $? "stop hostapd"
rm /var/run/hostapd.pid &> /dev/null
return $?
}
case "$1" in
start|stop|restart|reload|help)
"$1"
;;
*)
help
;;
esac
return $?
+13 -8
View File
@@ -5,15 +5,20 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Settin up hostname"
/usr/bin/hosname -F /etc/hostname
check $? "Set up hostname"
return $?
}
stop() {
return
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Setting up hostname\n$RESET"
/usr/bin/hosname -F /etc/hostname
check $? "Set up hostname"
;;
stop)
;;
restart|reload)
start|stop|restart|reload|help)
"$1"
;;
*)
help
+18 -14
View File
@@ -5,21 +5,25 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
otify "Starting httpd"
/usr/bin/httpd -h /srv/www
check $? "start httpd"
echo $(pgrep httpd) > /var/run/httpd.pid
return $?
}
stop() {
notify "Stopping httpd"
kill $(cat /var/run/httpd.pid)
check $? "stop httpd"
rm /var/run/httpd.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting httpd\n$RESET"
/usr/bin/httpd -h /srv/www
check $? "start httpd"
echo $(pgrep httpd) > /var/run/httpd.pid
;;
stop)
printf "$BBLUE**$BYELLOW Stopping httpd\n$RESET"
kill $(cat /var/run/httpd.pid)
check $? "stop httpd"
rm /var/run/httpd.pid
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
DAEMON="iptables"
IPTABLES_ARGS=""
start() {
notify "Starting $DAEMON"
iptables-restore /etc/iptables.conf
check $? "start $DAEMON"
return $?
}
stop () {
notify "Stopping $DAEMON"
iptables -F
check $? "stop $DAEMON"
return $?
}
save() {
notify "Saving %s: $DAEMON"
iptables-save -f /etc/iptables.conf
check $? "saving %s: $DAEMON"
return $?
}
case "$1" in
start|stop|restart|reload|save|help)
"$1"
;;
*)
help
;;
esac
return $?
+17 -13
View File
@@ -5,20 +5,24 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting klogd"
/usr/bin/klogd
check $? "start klogd"
return $?
}
stop() {
notify "Stopping klogd"
kill $(cat /var/run/klogd.pid)
check $? "stop klogd"
rm /var/run/klogd.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting klogd\n$RESET"
/usr/bin/klogd
check $? "start klogd"
;;
stop)
printf "$BBLUE**$BYELLOW Stopping klogd\n$RESET"
kill $(cat /var/run/klogd.pid)
check $? "stop klogd"
rm /var/run/klogd.pid &> /dev/null
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+18 -16
View File
@@ -5,23 +5,25 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting networking"
/usr/bin/ifup -a
check $? "networking"
echo $! > /var/run/networking.pid
return $?
}
stop() {
notify "Stopping networking"
/usr/bin/ifdown -a
check $? "Stop networking"
rm /var/run/networking.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting networking\n$RESET"
/usr/bin/ifup -a
check $? "networking"
echo $! > /var/run/networking.pid
;;
stop)
printf "$BBLUE**$BYELLOW Stopping netowrking\n$RESET"
/usr/bin/ifdown -a
check $? "Stop networking"
if [ -f /var/run/neworking.pid ]; then
rm /var/run/networking.pid
fi
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting nginx"
nginx
check $? "start nginx"
echo $(pgrep nginx) > /var/run/nginx.pid
return $?
}
stop() {
notify "Stopping nginx"
nginx -s stop
check $? "stop nginx"
rm /var/run/nginx.pid &> /dev/null
return $?
}
case "$1" in
start|stop|restart|reload)
"$1"
;;
*)
help
;;
esac
return $?
@@ -0,0 +1,37 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting openrouter software"
/usr/bin/auth_service &>/dev/null
check $? "start auth_service"
echo $(pgrep auth_service) > /var/run/auth_service.pid
/usr/bin/openrouter &> /dev/null
check $? "start openrouter"
echo $(pgrep openrouter) > /var/run/openrouter.pid
return $?
}
stop() {
notify "Stopping openrouter software"
kill $(cat /var/run/auth_service.pid)
check $? "stop auth_service"
kill $(cat /var/run/openrouter.pid)
check $? "stop openrouter"
rm /var/run/{auth_service.pid,openrouter.pid} &> /dev/null
return $?
}
case "$1" in
start|stop|restart|reload|help)
"$1"
;;
*)
help
;;
esac
return $?
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting sshd"
/usr/bin/sshd -D &
check $? "start sshd"
echo $(pgrep sshd) > /var/run/sshd.pid
return $?
}
stop() {
notify "Stopping sshd"
kill $(cat /var/run/sshd.pid)
check $? "stop sshd"
rm /var/run/sshd.pid &> /dev/null
return $?
}
case "$1" in
start|stop|restart|reload|help)
"$1"
;;
*)
help
;;
esac
return $?
+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Setting up sysctl"
sysctl -p & /dev/null
check $? "setting up sysctl"
return $?
}
stop() {
return
}
case "$1" in
start|stop|restart|reload|help)
"$1"
;;
*)
help
;;
esac
return $?
+17 -13
View File
@@ -5,20 +5,24 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting syslogd"
/usr/bin/syslogd
check $? "start syslogd"
return $?
}
stop() {
notify "Stopping syslogd"
kill $(cat /var/run/syslogd.pid)
check $? "stop syslogd"
rm /var/run/syslogd.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting syslogd\n$RESET"
/usr/bin/syslogd
check $? "start syslogd"
;;
stop)
printf "$BBLUE**$BYELLOW Stopping syslogd\n$RESET"
kill $(cat /var/run/syslogd.pid)
check $? "stop syslogd"
rm /var/run/syslogd.pid &> /dev/null
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+18 -14
View File
@@ -5,21 +5,25 @@
. /usr/lib/init/init-funcs.sh
#------------------------------------
start() {
notify "Starting telnetd"
/usr/bin/telnetd -p 23
check $? "start telnetd"
echo $(gprep telnetd) > /var/run/telnetd.pid
return $?
}
stop() {
notify "Stopping telnetd"
kill $(cat /var/run/telnetd.pid)
check $? "stop telnetd"
rm /var/run/telnetd.pid &> /dev/null
return $?
}
case "$1" in
start)
printf "$BBLUE**$BYELLOW Starting telnetd\n$RESET"
/usr/bin/telnetd -p 23
check $? "start telnetd"
echo $(gprep telnetd) > /var/run/telnetd.pid
;;
stop)
printf "$BBLUE**$BYELLOW Stopping telnetd\n$RESET"
kill $(cat /var/run/telnetd.pid)
check $? "stop telnetd"
rm /var/run/telnetd.pid &> /dev/null
;;
restart|reload)
restart
start|stop|restart|reload|help)
"$1"
;;
*)
help
+6 -6
View File
@@ -7,10 +7,10 @@
07dnsmasq
08dnsd
09telnetd
10ssh
10sshd
11iptables
12openrouterinit
13ftpd
14hostapd
15httpd
16nginx
12ftpd
13hostapd
14httpd
15nginx
16openrouterinit