initial commit
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
01hostname
|
||||
02klogd
|
||||
03syslogd
|
||||
04swap
|
||||
05networking
|
||||
06sysctl
|
||||
07dnsmasq
|
||||
08dnsd
|
||||
09telnetd
|
||||
10sshd
|
||||
11iptables
|
||||
12ftpd
|
||||
13hostapd
|
||||
14httpd
|
||||
15nginx
|
||||
16openrouterinit
|
||||
17dropbear
|
||||
18gitea
|
||||
@@ -0,0 +1,151 @@
|
||||
#!/bin/sh
|
||||
|
||||
########## ##########
|
||||
########## ##########
|
||||
## ## ##
|
||||
## ##
|
||||
## ## - RC BOOT SCRIPTS MANAGER FOR SIMPLE LINUX
|
||||
## ## - AUTHOR -- TOLA MIRONCENKO
|
||||
## ##
|
||||
## ##
|
||||
## ##########
|
||||
## ##########
|
||||
|
||||
rootdir=/
|
||||
|
||||
#----- colors -------
|
||||
RESET="\033[0m"
|
||||
GREEN="\033[0;32m"
|
||||
BLUE="\033[0;34m"
|
||||
YELLOW="\033[1;33m"
|
||||
BWHITE="\033[1;37m"
|
||||
BRED="\033[1;31m"
|
||||
#--------------------
|
||||
|
||||
#------------------------ add to boot function --------------
|
||||
add() {
|
||||
resultlink=$(cat $rootdir/usr/share/rc/orders | grep $1)
|
||||
if [ -f $rootdir/usr/lib/init/services/$1.service ] && [ $resultlink ]; then
|
||||
cd $rootdir/etc/rc.d
|
||||
ln -sv $rootdir/usr/lib/init/services/$1.service "$resultlink" &> /dev/null
|
||||
printf "$BLUE**$GREEN SUCCESS:$BWHITE added $1 to init.\n$RESET"
|
||||
else
|
||||
help
|
||||
fi
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#--------------------- del from boot function ---------------
|
||||
del() {
|
||||
filetoremove=$(find $rootdir/etc/rc.d/ | grep $1 )
|
||||
if [ $filetoremove ]; then
|
||||
rm -v $filetoremove &> /dev/null
|
||||
printf "$BLUE**$GREEN SUCCESS:$BWHITE removed $1 from init.\n$RESET"
|
||||
else
|
||||
help
|
||||
fi
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#---------------------- start daemon function ---------------
|
||||
start() {
|
||||
if [ -f $rootdir/etc/init.d/$1 ]; then
|
||||
$rootdir/etc/init.d/$1 start
|
||||
else
|
||||
help
|
||||
fi
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#---------------- stop daemon function ----------------------
|
||||
stop() {
|
||||
if [ -f $rootdir/etc/init.d/$1 ]; then
|
||||
$rootdir/etc/init.d/$1 stop
|
||||
else
|
||||
help
|
||||
fi
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#------------- restart daemon function ----------------------
|
||||
restart() {
|
||||
if [ -f $rootdir/etc/init.d/$1 ]; then
|
||||
$rootdir/etc/init.d/$1 restart
|
||||
else
|
||||
help
|
||||
fi
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#------------------ list services ---------------------------
|
||||
list() {
|
||||
ls --color $rootdir/usr/lib/init/services
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#------------------ list enabled services -------------------
|
||||
bootlist() {
|
||||
ls --color $rootdir/etc/rc.d
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#------------------ service status --------------------------
|
||||
status() {
|
||||
if [[ "$1" == "" ]]; then
|
||||
help
|
||||
exit 0
|
||||
fi
|
||||
if [[ "$(ls $rootdir/etc/init.d | grep $1)" == "" ]]; then
|
||||
printf "$YELLOW**$BRED error:$RESET can't find service /etc/init.d/$1\n"
|
||||
exit 1
|
||||
fi
|
||||
printf "$YELLOW**$GREEN $1$RESET\n"
|
||||
rcdservice=$(ls $rootdir/etc/rc.d | grep $1 2> /dev/null)
|
||||
if [[ "$rcdservice" == "" ]]; then
|
||||
printf "Loaded:$YELLOW unloaded$RESET (/etc/rc.d)\n"
|
||||
else
|
||||
printf "Loaded:$GREEN loaded$RESET (/etc/rc.d/$rcdservice)\n"
|
||||
fi
|
||||
servicepid=$(ls $rootdir/var/run | grep $1)
|
||||
if [[ "$servicepid" == "" ]]; then
|
||||
printf "Active: deactive (${YELLOW}deactive$RESET)\n"
|
||||
else
|
||||
printf "Active: active (${GREEN}running$RESET); pid (/var/run/$servicepid)\n"
|
||||
fi
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
#-------------- print help function -------------------------
|
||||
help() {
|
||||
printf "
|
||||
$BLUE**$GREEN rc usage$RESET:$BWHITE
|
||||
rc add [init.d script name] - add service on boot
|
||||
rc del [init.d script name] - delete service from boot
|
||||
rc start [init.d script name] - start service
|
||||
rc stop [init.d script name] - stop service
|
||||
rc restart [init.d script name] - restart service
|
||||
rc list - list all services
|
||||
rc bootlist - list enabled services
|
||||
rc status [init.d script name] - check service status
|
||||
|
||||
$BLUE**$GREEN examples$RESET:$BWHITE
|
||||
rc add httpd
|
||||
rc del httpd
|
||||
rc start httpd
|
||||
rc stop httpd
|
||||
rc restart httpd
|
||||
rc list
|
||||
rc bootlist\n$RESET"
|
||||
}
|
||||
#------------------------------------------------------------
|
||||
|
||||
command="$1"
|
||||
|
||||
case ${command} in
|
||||
add|del|start|stop|restart|list|bootlist|status)
|
||||
"$1" $2 $3
|
||||
;;
|
||||
*)
|
||||
help
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user