rewrite esv (2.0.0)
This commit is contained in:
parent
970cc8e411
commit
c3f4f3d81c
136
src/esv/esv
136
src/esv/esv
@ -1,77 +1,101 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Everest service manager
|
# esv - everest service manager
|
||||||
# (C) 2022 Everest Developers
|
|
||||||
# This program is free software: you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License as published by the
|
|
||||||
# Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
preload() {
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
. /etc/esv.conf
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
if [ "$?" != "0" ]; then
|
||||||
# See the GNU General Public License for more details.
|
printf "error while parsing esv config file\n"
|
||||||
# You should have received a copy of the GNU General Public License along with this program.
|
exit 1
|
||||||
# If not, see <https://www.gnu.org/licenses/>.
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
source /etc/esv.conf
|
helpmsg_big() {
|
||||||
#source $(pwd)/esv.conf # for testing purposes
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
printf "esv - Everest Service Manager\n"
|
printf "esv - Everest Service Manager\n"
|
||||||
printf "usage: esv {action} {service-name}\n"
|
printf "usage: esv [start] [stop] [restart] [-h/--help] [-v/--version] service-name\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "esv {start} - start a service\n"
|
printf "esv {start} start a service\n"
|
||||||
printf "esv {stop} - stop a currently running service\n"
|
printf "esv {stop} stop a running service\n"
|
||||||
printf "esv {restart} - restart a currently running service\n"
|
printf "esv {restart} restart a running service\n"
|
||||||
printf "esv {-h|--help} - print this message and exit\n"
|
printf "esv {-h/--help} print this message and exit\n"
|
||||||
printf "esv {-v|--version} - print the version and exit\n"
|
printf "esv {-v/--version} print the version and exit\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "(C) 2022 Everest Developers\n"
|
printf "This program is free software.\n"
|
||||||
printf "This program is free software: you can redistribute it and/or modify it\n"
|
printf "See the GNU GPL version 3 for details.\n"
|
||||||
printf "under the terms of the GNU General Public License as published by the\n"
|
|
||||||
printf "Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n"
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
}
|
||||||
start)
|
|
||||||
printf "$blue starting service $2...\n $reset"
|
helpmsg_small() {
|
||||||
$SRV_DIR/$2/$RUN
|
printf "usage: esv [start] [stop] [restart] [-n/--help] [-v/--version] service-name\n"
|
||||||
if [ "$?" != "0" ]; then
|
exit 1
|
||||||
printf "$red service $2 could not start $reset \n"
|
}
|
||||||
|
|
||||||
|
startsv() {
|
||||||
|
if [ "$2" == "" ]; then
|
||||||
|
printf "${red}you must specify a service name${reset}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
printf "$green service $2 started succesfully $reset \n"
|
printf "${blue}starting service ${2}...${reset}\n"
|
||||||
exit 0
|
${SRV_DIR}/${2}/${RUN}
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
printf "$blue stopping service $2...$reset \n"
|
|
||||||
$SRV_DIR/$2/$STOP
|
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
printf "$red service $2 could not stop $reset \n"
|
printf "${red}service ${2} could not start${reset}\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
printf "$green service $2 stopped succesfully $reset \n"
|
printf "${green}service ${2} started successfully${reset}\n"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
}
|
||||||
restart)
|
|
||||||
printf "$blue restarting service $2... $reset \n"
|
stopsv() {
|
||||||
$SRV_DIR/$2/$STOP && $SRV_DIR/$2/$RUN
|
if [ "$?" == "" ]; then
|
||||||
if [ "$?" != "0" ]; then
|
printf "${red}you must specify a service name${reset}\n"
|
||||||
printf "$red service $2 could not restart $reset \n"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
printf "$green service $2 restarted successfully $reset \n"
|
printf "${blue}stopping service ${2}...${reset}\n"
|
||||||
|
${SRV_DIR}/${2}/${STOP}
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
printf "${red}service ${2} could not stop${reset}\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "${green}service ${2} stopped successfully${reset}\n"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
restartsv() {
|
||||||
|
if [ "$2" == "" ]; then
|
||||||
|
printf "${red}you must specify a service name${reset}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "${blue}restarting service ${2}...${reset}\n"
|
||||||
|
${SRV_DIR}/${2}/${STOP} && ${SRV_DIR}/${2}/${RUN}
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
printf "${red}service ${2} could not restart${reset}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "${green}service ${2} restarted successfully${reset}\n"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
printver() {
|
||||||
|
printf "${blue}esv v2.0.0${reset}\n"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
helpmsg_big "$@"
|
||||||
;;
|
;;
|
||||||
-v|--version)
|
-v|--version)
|
||||||
printf "$blue esv v1.0.1 $reset \n"
|
printver "$@"
|
||||||
exit 0
|
;;
|
||||||
|
start)
|
||||||
|
startsv "$@"
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stopsv "$@"
|
||||||
|
;;
|
||||||
|
restartsv)
|
||||||
|
restartsv "$@"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "$red invalid option specified, see 'esv --help' $reset \n"
|
helpmsg_small "$@"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
|
||||||
|
|
||||||
printf "$red no option specified, see 'esv --help' $reset \n"
|
|
||||||
|
77
src/esv/esv.old
Executable file
77
src/esv/esv.old
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Everest service manager
|
||||||
|
# (C) 2022 Everest Developers
|
||||||
|
# This program is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by the
|
||||||
|
# Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the GNU General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU General Public License along with this program.
|
||||||
|
# If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
source /etc/esv.conf
|
||||||
|
#source $(pwd)/esv.conf # for testing purposes
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
printf "esv - Everest Service Manager\n"
|
||||||
|
printf "usage: esv {action} {service-name}\n"
|
||||||
|
printf "\n"
|
||||||
|
printf "esv {start} - start a service\n"
|
||||||
|
printf "esv {stop} - stop a currently running service\n"
|
||||||
|
printf "esv {restart} - restart a currently running service\n"
|
||||||
|
printf "esv {-h|--help} - print this message and exit\n"
|
||||||
|
printf "esv {-v|--version} - print the version and exit\n"
|
||||||
|
printf "\n"
|
||||||
|
printf "(C) 2022 Everest Developers\n"
|
||||||
|
printf "This program is free software: you can redistribute it and/or modify it\n"
|
||||||
|
printf "under the terms of the GNU General Public License as published by the\n"
|
||||||
|
printf "Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
start)
|
||||||
|
printf "$blue starting service $2...\n $reset"
|
||||||
|
$SRV_DIR/$2/$RUN
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
printf "$red service $2 could not start $reset \n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "$green service $2 started succesfully $reset \n"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
printf "$blue stopping service $2...$reset \n"
|
||||||
|
$SRV_DIR/$2/$STOP
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
printf "$red service $2 could not stop $reset \n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "$green service $2 stopped succesfully $reset \n"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
printf "$blue restarting service $2... $reset \n"
|
||||||
|
$SRV_DIR/$2/$STOP && $SRV_DIR/$2/$RUN
|
||||||
|
if [ "$?" != "0" ]; then
|
||||||
|
printf "$red service $2 could not restart $reset \n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "$green service $2 restarted successfully $reset \n"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
-v|--version)
|
||||||
|
printf "$blue esv v1.0.1 $reset \n"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf "$red invalid option specified, see 'esv --help' $reset \n"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
printf "$red no option specified, see 'esv --help' $reset \n"
|
0
src/esv/lib/libesv
Normal file → Executable file
0
src/esv/lib/libesv
Normal file → Executable file
@ -1,12 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
chroot "$EV" /usr/bin/env -i \
|
chroot $1 /bin/sh --userspec=USER:GROUP
|
||||||
HOME=/root \
|
|
||||||
TERM="$TERM" \
|
|
||||||
PS1='[everest-chroot] \u:\w \$ ' \
|
|
||||||
PATH=/usr/bin:/usr/sbin \
|
|
||||||
/bin/bash --login
|
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
printf "\033[1;31m [ \xE2\x9C\x95 ] \033[m Could not enter chroot environment.\n" 1>&2
|
printf "[ X ] Failed to change root to $1.\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user