initial commit

This commit is contained in:
wt committed 2024-11-01 12:46:26 +07:00
commit cf0750198d
27 files changed
+929

No files matched your search

+82
View File
@@ -0,0 +1,82 @@
#!/bin/sh
#--- reset colors ---
RESET="\033[0m"
#--------------------
#--------- regularcolrs ---------
GREEN="\033[0;32m" #GREEN
BLUE="\033[0;34m" #BLUE
YELLOW="\033[1;33m" #YELLOW
RED="\033[0;31m" #RED
BLACK="\033[0;30m" #BLACK
PURPLE="\033[0;35m" #PURPLE
CYAN="\033[0;36m" #CYAN
WHITE="\033[0;37m" #WHITE
#--------------------------------
#-------- bold ------------------
BBLACK="\033[1;30m" #BLACK
BRED="\033[1;31m" #RED
BGREEN="\033[1;32m" #GREEN
BYELLOW="\033[1;33m" #YELLOW
BBLUE="\033[1;34m" #BLUE
BPURPLE="\033[1;35m" #PURPLE
BCYAN="\033[1;36m" #CYAN
BWHITE="\033[1;37m" #WHITE
#--------------------------------
#-------- Underline -------------
UBLACK="\033[4;30m" #BLACK
URED="\033[4;31m" #RED
UGREEN="\033[4;32m" #GREEN
UYELLOW="\033[4;33m" #YELLOW
UBLUE="\033[4;34m" #BLUE
UPURPLE="\033[4;35m" #PURPLE
UCYAN="\033[4;36m" #CYAN
UWHITE="\033[4;37m" #WHITE
#--------------------------------
#--------- Background -----------
ON_BLACK="\033[40m" #BLACK
ON_RED="\033[41m" #RED
ON_GREEN="\033[42m" #GREEN
ON_YELLOW="\033[43m" #YELLOW
ON_BLUE="\033[44m" #BLUE
ON_PURPLE="\033[45m" #PURPLE
ON_CYAN="\033[46m" #CYAN
ON_WHITE="\033[47m" #WHITE
#--------------------------------
#------ HighIntensity -----------
IBLACK="\033[0;90m" #BLACK
IRED="\033[0;91m" #RED
IGREEN="\033[0;92m" #GREEN
IYELLOW="\033[0;93m" #YELLOW
IBLUE="\033[0;94m" #BLUE
IPURPLE="\033[0;95m" #PURPLE
ICYAN="\033[0;96m" #CYAN
IWHITE="\033[0;97m" #WHITE
#--------------------------------
#------ BoldHighIntensity -------
BIBLACK="\033[1;90m" #BLACK
BIRED="\033[1;91m" #RED
BIGREEN="\033[1;92m" #GREEN
BIYELLOW="\033[1;93m" #YELLOW
BIBLUE="\033[1;94m" #BLUE
BIPURPLE="\033[1;95m" #PURPLE
BICYAN="\033[1;96m" #CYAN
BIWHITE="\033[1;97m" #WHITE
#--------------------------------
#--- HighIntensitybackgrounds ---
ON_IBLACK="\033[0;100m" #BLACK
ON_IRED="\033[0;101m" #RED
ON_IGREEN="\033[0;102m" #GREEN
ON_IYELLOW="\033[0;103m" #YELLOW
ON_IBLUE="\033[0;104m" #BLUE
ON_IPURPLE="\033[0;105m" #PURPLE
ON_ICYAN="\033[0;106m" #CYAN
ON_IWHITE="\033[0;107m" #WHITE
#--------------------------------
+56
View File
@@ -0,0 +1,56 @@
#!/bin/sh
#--- import colors ---
. /usr/lib/init/colors.sh
#---------------------
#------------ rc function to poweron or poweroff ------------
rc() {
if [ -d /etc/rc.d ] && [ $0 == "/etc/init.d/rcK" ]; then
for service in $(ls -r /etc/rc.d); do
/etc/rc.d/$service stop
done
return 1
fi
for service in /etc/rc.d/??*; do
[ ! -f "$service" ] && continue
case "$service" in
*.sh)
(
trap - INT QUIT TSTP
set start
. $service
)
;;
*)
$service start
;;
esac
done
sleep 1
return 1
}
#------------------------------------------------------------
#--- restart function ---
restart() {
$0 stop
$0 start
}
#------------------------
#--- help function ---
help() {
echo "$0 init script usage: $0 {start|stop|restart|reload}"
}
#---------------------
#------------ check status function ------------
check() {
if [ $1 -ne 0 ]; then
printf "$BBLUE**$BRED ERROR: $2\n$RESET"
return
fi
printf "$BBLUE**$BGREEN SUCCESS: $2\n$RESET"
}
#-----------------------------------------------
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
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
;;
*)
help
return 1
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
#------------------------------------
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
;;
*)
help
;;
esac
return $?
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
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
;;
*)
help
return 1
esac
return $?
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
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)
;;
*)
help
return 1
esac
return $?
+29
View File
@@ -0,0 +1,29 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
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
;;
*)
help
return 1
;;
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
#------------------------------------
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
;;
*)
help
;;
esac
reurn $?
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
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
;;
*)
help
return 1
esac
return $?
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
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
;;
*)
help
return 1
;;
esac
return $?
+28
View File
@@ -0,0 +1,28 @@
#!/bin/sh
#--- import colors and init-funcs ---
. /usr/lib/init/colors.sh
. /usr/lib/init/init-funcs.sh
#------------------------------------
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
;;
*)
help
;;
esac
return $?