From 17d4590426e6582b993834b6843deb404b83eba1 Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Wed, 22 Mar 2023 14:00:58 -0400 Subject: [PATCH] esv v3 --- README | 3 +- install/emkfile | 12 ++-- install/install.conf | 0 src/ecrypt/ecrypt-genkey.sh | 9 +++ src/esv/esv3/README.md | 35 ++++++++++++ src/esv/esv3/esv | 110 ++++++++++++++++++++++++++++++++++++ src/esv/esv3/esv.conf | 13 +++++ src/gpc/gpc | 2 + 8 files changed, 177 insertions(+), 7 deletions(-) create mode 100644 install/install.conf create mode 100644 src/ecrypt/ecrypt-genkey.sh create mode 100644 src/esv/esv3/README.md create mode 100755 src/esv/esv3/esv create mode 100755 src/esv/esv3/esv.conf diff --git a/README b/README index e8be45d..86f663a 100644 --- a/README +++ b/README @@ -31,4 +31,5 @@ OR Install only certain tools ∟ libesv - backend for esv gpc - Glacier Package Checker ecrypt - Everest Encryption Tools - emk - Simple shell script based build system + emk - Simple shell script based build system + mkskel - Create a filesystem skeleton diff --git a/install/emkfile b/install/emkfile index a1e5a05..1c76917 100755 --- a/install/emkfile +++ b/install/emkfile @@ -111,9 +111,9 @@ distclean_pkg() { # These should not be modified unless adding support for custom funtions case $1 in - help) # Put a list of all available tasks here + showhelp) # Put a list of all available tasks here #printf "make - compile program\n" - #printf "install - install program\n" + printf "install - install every tool under this repository\n" #printf "clean - clean all files generated by make\n" #printf "distclean - clean all files not in the source tree\n" #exit 0 @@ -134,8 +134,8 @@ case $1 in distclean_pkg "$@" exit 0 ;; - *) - printf "emk ${red}ERR${reset} | no such task exists\n" - exit 1 - ;; + #*) + # printf "emk ${red}ERR${reset} | no such task exists\n" + # exit 1 + #;; esac diff --git a/install/install.conf b/install/install.conf new file mode 100644 index 0000000..e69de29 diff --git a/src/ecrypt/ecrypt-genkey.sh b/src/ecrypt/ecrypt-genkey.sh new file mode 100644 index 0000000..443f0b4 --- /dev/null +++ b/src/ecrypt/ecrypt-genkey.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env /bin/sh + +# ecrypt-genkey - A simple bash script for generating keys, passwords, etc +# +# Copyright (C) 2023 Everest Linux +# +# This program is free software. See the GNU GPL v3.0 for more information/ + +letters=("a" "b" "c" "d" "e" "f" diff --git a/src/esv/esv3/README.md b/src/esv/esv3/README.md new file mode 100644 index 0000000..92d746d --- /dev/null +++ b/src/esv/esv3/README.md @@ -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 +``` diff --git a/src/esv/esv3/esv b/src/esv/esv3/esv new file mode 100755 index 0000000..caa6722 --- /dev/null +++ b/src/esv/esv3/esv @@ -0,0 +1,110 @@ +#!/bin/sh +# esv - Everest Service Manager + +source /etc/esv.conf + if [ "$?" != "0" ]; then + printf "error while parsing esv config file, does it exist?\n" + exit 1 + fi + +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} + 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} + 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} + 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 diff --git a/src/esv/esv3/esv.conf b/src/esv/esv3/esv.conf new file mode 100755 index 0000000..f8f095f --- /dev/null +++ b/src/esv/esv3/esv.conf @@ -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 diff --git a/src/gpc/gpc b/src/gpc/gpc index 019353c..347c000 100755 --- a/src/gpc/gpc +++ b/src/gpc/gpc @@ -79,6 +79,8 @@ preload() { fi } +preload "$@" + case $1 in -h|--help) helpmsg "$@"