This commit is contained in:
Liam Waldron 2023-03-24 13:28:43 -04:00
commit b5c2e7709d
4 changed files with 189 additions and 0 deletions

35
README.md Normal file
View File

@ -0,0 +1,35 @@
## esv
esv is a simple service manager, compatible with sysv init scripts. It is intended to interface well wtith
busybox init, however it also works well with sysvinit.
## Get started
esv requires the following packages:
- Bash (esv runtime)
To install esv, clone the everest-tools repository:
```
git clone https://git.everestlinux.org/EverestLinux/everest-tools
```
Inside `src/esv/esv3`, edit install.conf.dist and ensure all options are adequate, and save as install.conf:
```
EDITOR=your_editor_here
$EDITOR install.conf.dist
```
Run `build.sh` as root:
```
doas ./build.sh install
# OR
sudo ./build.sh install
# OR
su -c ./build.sh install
```
## Usage
```
esv {start,stop,restart} SERVICE_NAME # start a service
esv {-h,--help} # show a help message
esv {-v,--version} # show the version
```

111
src/bin/esv Executable file
View File

@ -0,0 +1,111 @@
#!/bin/sh
# esv - Everest Service Manager
if [ ! -f "/etc/esv.conf" ]; then
printf "error: unable to parse /etc/esv.conf, does it exist?\n"
exit 1
fi
source /etc/esv.conf
helpmsg_big() {
printf "${0} - Everest Service Manager\n"
printf "usage: ${0} [start] [stop] [restart] [-h] [-v] SERVICE NAME\n"
printf "\n"
printf "${0} {start} start a service\n"
printf "${0} {stop} stop a service\n"
printf "${0} {restart} restart a running service\n"
printf "${0} {-h/--help} print this message and exit\n"
printf "${0} {-v/--version} print the version and exit\n"
printf "\n"
printf "This program is free software.\n"
printf "See the GNU GPL version 3 for details.\n"
}
helpmsg_small() {
printf "usage: ${0} [start] [stop] [restart] [-h] [-v] SERVICE NAME\n"
}
check_if_exists() {
SV="${@}"
for SRV in ${SV[@]}; do
if [ ! -f "${SRV_DIR}/${SRV}" ]; then
printf "${red}service ${SRV} does not exist${reset}\n"
exit 1
fi
done
}
startsv() {
SV="${@}"
if [ "$SV" = "" ]; then
printf "${red}you must specify a service name${reset}\n"
exit 1
fi
printf "${blue}starting: $SV...${reset}\n"
for SRV in ${SV[@]}; do
source ${SRV_DIR}/${SRV}
run
done
}
stopsv() {
SV="${@}"
if [ "$SV" = "" ]; then
printf "${red}you must specify a service name${reset}\n"
exit 1
fi
printf "${blue}stopping: $SV...${reset}\n"
for SRV in ${SV[@]}; do
source ${SRV_DIR}/${SRV}
stop
done
}
restartsv() {
SV="${@}"
if [ "$V" = "" ]; then
printf "${red}you must specify a service name${reset}\n"
exit 1
fi
printf "${blue} restarting: $SV...${reset}\n"
for SRV in ${SV[@]}; do
source ${SRV_DIR}/${SRV}
restart
done
}
printver() {
printf "${blue}esv v3.0.0${reset}\n"
}
case $1 in
-h|--help)
helpmsg_big
exit 0
;;
-v|--version)
printver
exit 0
;;
start)
shift
check_if_exists "$@"
startsv "$@"
;;
stop)
shift
check_if_exists "$@"
stopsv "$@"
;;
restart)
shift
check_if_exists "$@"
restartsv "$@"
;;
*)
helpmsg_small "$@"
esac

13
src/etc/esv.conf Executable file
View File

@ -0,0 +1,13 @@
# /etc/esv.conf
# Where services are stored.
# On Everest, this is /etc/init.d
export SRV_DIR="/etc/init.d"
# Colors
export red="\033[1;31m"
export green="\033[1;32m"
export blue="\033[1;34m"
export reset="\033[m"
# end /etc/esv.conf

30
src/man/esv.1 Normal file
View File

@ -0,0 +1,30 @@
.\" Manpage for esv.
.TH man 1 "24 March 2023" "3.0" "Everest Linux Manual"
.SH NAME
esv \- start, stop, and restart services from sysv-style init scripts
.SH SYNPOSIS
esv [start] [stop] [restart] [-h] [-v]
.SH DESCRIPTION
esv is a service manager for Everest Linux which interfaces with already-existing sysv-style init scripts. It is written in POSIX sh, and as such interfaces well with these scripts.
.SH OPTIONS
.TP
.BR start
starts a daemon
.TP
.BR stop
stops a daemon
.TP
.BR restart
restarts a daemon
.TP
.BR \-h
shows a help message
.TP
.BR \-v
shows the version
.SH SEE ALSO
ecrypt(1) gpkg(8)
.SH BUGS
Report all bugs on the issues page at https://git.everestlinux.org/EverestLinux/esv
.SH AUTHOR
Liam Waldron (liamwaldron@everestlinux.org)