From c3bbf342f14b7ac696e4c4f97a84949b312b3fb3 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 22 Sep 2019 15:03:24 -0400 Subject: [PATCH] rename to tilde --- Makefile | 2 +- README.md | 32 +++++------ envs => tilde | 131 ++++++++++++++-------------------------------- envs.1 => tilde.1 | 34 ++++++------ 4 files changed, 73 insertions(+), 126 deletions(-) rename envs => tilde (64%) rename envs.1 => tilde.1 (53%) diff --git a/Makefile b/Makefile index 74b652f..c8e0265 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BASENAME ?= envs +BASENAME ?= tilde PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin MANDIR ?= $(PREFIX)/share/man diff --git a/README.md b/README.md index a7b812f..68939bd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -# `envs` - manage users_info.json entrys and user-submitted scripts +# `tilde` - manage users_info.json entrys and user-submitted scripts forked from [tilde](https://tildegit.org/team/tilde-launcher) +adding in updates from [envs.net fork](https://git.envs.net/envs/envs_launcher/) ``` wrapper for user-submitted scripts and users_info.json entrys @@ -8,26 +9,27 @@ supports user settings, submission and admin approval User Scripts -usage: envs [help|list|submit|about|script_name] - envs list - show a list of approved userscripts - envs submit - start the submission flow for your own script - envs about - get the description for script_name - envs - run script_name with all remaining args are passed to the script +usage: tilde [help|list|submit|about|script_name] + tilde list - show a list of approved userscripts + tilde submit - start the submission flow for your own script + tilde about - get the description for script_name + tilde - run script_name with all remaining args are passed to the script User json-File Infomations -usage: envs [show]|[edit]|[get name]|[set name value]|[unset name] - envs show - show your config file - envs edit - edit your config file - envs get - show a entry from your config - envs set <'value'> - set a entry to your config - envs unset - unset a entry from your config +usage: tilde [show]|[edit]|[get name]|[set name value]|[unset name] + tilde show - show your config file + tilde edit - edit your config file + tilde get - show a entry from your config + tilde set <'value'> - set a entry to your config + tilde unset - unset a entry from your config ``` -approved scripts are placed in /envs/bin and listed with `envs list` +approved scripts are placed in /tilde/bin and listed with `tilde list` submissions use sendmail to notify an admin. -admins can use `sudo envs approve` and `sudo envs revoke `. +admins can use `sudo tilde approve` and `sudo tilde revoke `. + +users can also manage youre `users_info.json` entrys from the `~/.tilde`-file. -users can also manage youre `users_info.json` entrys from the `~/.envs`-file. diff --git a/envs b/tilde similarity index 64% rename from envs rename to tilde index f9a4f03..d386b14 100755 --- a/envs +++ b/tilde @@ -1,6 +1,6 @@ #!/usr/bin/env bash # --------------------------------------------------------------------------- -# envs - manage users_info.json entrys and user-submitted scripts +# tilde - manage user-submitted scripts # forked from tilde.team # Copyright 2018-2019, Ben Harris @@ -17,7 +17,7 @@ # GNU General Public License at for # more details. -# Usage: envs [-h|--help] +# Usage: tilde [-h|--help] # --------------------------------------------------------------------------- export TERM=xterm-256color @@ -25,7 +25,7 @@ export TERM=xterm-256color PROGNAME=${0##*/} VERSION="0.0.5" -INFO_FILE="/home/$(id -un)/.envs" +INFO_FILE="/home/$(id -un)/.tilde" ### @@ -79,23 +79,15 @@ usage() { printf ' %s submit - start the submission flow for your own script\n' "$PROGNAME" [[ $(id -u) == 0 ]] && { printf ' %s approve - enter the approval queue\n' "$PROGNAME" - printf ' %s revoke - send a script back to the author and remove from /envs/bin\n' "$PROGNAME" + printf ' %s revoke - send a script back to the author and remove from /tilde/bin\n' "$PROGNAME" } printf ' %s about - get the description for script_name\n' "$PROGNAME" printf ' %s - run script_name with all remaining args are passed to the script\n' "$PROGNAME" - printf '\n%sUser json-File Infomations%s\n' "$(tput setaf 6)" "$(tput sgr0)" - printf '\nusage: %s [show]|[edit]|[get name]|[set name value]|[unset name]\n' "$PROGNAME" - printf ' %s show - show your config file\n' "$PROGNAME" - printf ' %s edit - edit your config file\n' "$PROGNAME" - printf ' %s get - show a entry from your config\n' "$PROGNAME" - printf " %s set <'value'> - set a entry to your config\n" "$PROGNAME" - printf ' %s unset - unset a entry from your config\n' "$PROGNAME" - - if [[ :$PATH: != *:"/envs/bin":* ]] ; then - printf "\nadd /envs/bin to your PATH to use approved scripts without this wrapper\n" + if [[ :$PATH: != *:"/tilde/bin":* ]] ; then + printf "\nadd /tilde/bin to your PATH to use approved scripts without this wrapper\n" printf "if you're using bash, run the following to add it quickly\n" - printf " echo 'export PATH=\$PATH:/envs/bin' >> ~/.bashrc && source ~/.bashrc\n" + printf " echo 'export PATH=\$PATH:/tilde/bin' >> ~/.bashrc && source ~/.bashrc\n" fi } @@ -103,7 +95,7 @@ usage() { help_message() { cat <<- EOF $(tput setaf 6)$PROGNAME (ver. $VERSION)$(tput sgr0) -wrapper for user-submitted scripts and users_info.json entrys +wrapper for user-submitted scripts supports user settings, submission and admin approval $(usage) EOF @@ -116,10 +108,10 @@ verify_script_name() { if [[ "$(type "$1" > /dev/null 2>&1)" ]]; then error_exit "$1 already exists. rename your script and try again." fi - [[ -x /envs/bin/"$1" ]] && error_exit "$1 is already taken. rename your script and try again." + [[ -x /tilde/bin/"$1" ]] && error_exit "$1 is already taken. rename your script and try again." case "$1" in - help|about|description|desc|list|ls|submit|apropos|approve|revoke|show|edit|get|set|unset) - error_exit "$1 is a subcommand of envs. rename your script and try again.";; + help|about|description|desc|list|ls|submit|apropos|approve|revoke|show) + error_exit "$1 is a subcommand of tilde. rename your script and try again.";; *) return;; esac @@ -141,11 +133,11 @@ EOF mail_body() { cat <<- EOF -Subject: envs script submission from $USER -From: $USER@envs.net -To: creme@envs.net +Subject: tilde script submission from $USER +From: $USER@tilde.club +To: root@tilde.club -envs script submission from $USER +tilde script submission from $USER script name: $1 @@ -155,35 +147,13 @@ description: $2 ----------------------------------------------------------------------- -you'll find the script and description in: /envs/pending-submissions/$USER/$1 +you'll find the script and description in: /tilde/pending-submissions/$USER/$1 run this to see the approval queue: -sudo envs approve +sudo tilde approve EOF } -# add default config if not exists -if [ ! -f "$INFO_FILE" ]; then - cat << EOF > "$INFO_FILE" -# -# ENVS.NET - user information config -# ( will be updated every hour ) -# here you can add more details to youre users_info.json part -# -desc=a short describtion or message - -# add more informations (max. 10 entrys) -#git= -#mastodon= -# you can also add a array with unlimeted entrys -#name=line1 -#name=line2 -#nametwo=line1 - -EOF -fi - - # Trap signals trap "signal_exit TERM" TERM HUP trap "signal_exit INT" INT @@ -207,18 +177,18 @@ case "$1" in list | ls) printf 'available scripts:\n\n' - for scr in /envs/bin/*; do + for scr in /tilde/bin/*; do script_name=$(basename "$scr") target=$(readlink -f "$scr") printf '%s%s by %s%s\n' "$(tput setaf 6)" "$script_name" "$(stat -c '%U' "$target")" "$(tput sgr0)" - cat /envs/descriptions/"$script_name" + cat /tilde/descriptions/"$script_name" printf '\n' done ;; about | apropos | description | desc) - if [[ -f /envs/descriptions/"$2" ]]; then - cat /envs/descriptions/"$2" + if [[ -f /tilde/descriptions/"$2" ]]; then + cat /tilde/descriptions/"$2" else printf '%s not found. try %s list to see available user scripts.\n' "$2" "$PROGNAME" fi @@ -235,7 +205,7 @@ case "$1" in if [[ -x "$HOME"/bin/"$script_name" ]]; then printf '\ncool, found your script\n' - [[ -x /envs/pending-submissions/"$USER"/"$script_name"/"$script_name" ]] && error_exit "you've already submitted $script_name" + [[ -x /tilde/pending-submissions/"$USER"/"$script_name"/"$script_name" ]] && error_exit "you've already submitted $script_name" else error_exit "$script_name not found in ~/bin" fi @@ -246,10 +216,10 @@ case "$1" in prompt_confirm "ready to submit?" || graceful_exit # submit now - mkdir -p /envs/pending-submissions/"$USER"/"$script_name" - ln -s "$HOME"/bin/"$script_name" /envs/pending-submissions/"$USER"/"$script_name"/"$script_name" - echo "$description" > /envs/pending-submissions/"$USER"/"$script_name"/description.txt - mail_body "$script_name" "$description" | /usr/sbin/sendmail creme + mkdir -p /tilde/pending-submissions/"$USER"/"$script_name" + ln -s "$HOME"/bin/"$script_name" /tilde/pending-submissions/"$USER"/"$script_name"/"$script_name" + echo "$description" > /tilde/pending-submissions/"$USER"/"$script_name"/description.txt + mail_body "$script_name" "$description" | /usr/sbin/sendmail root printf 'script submitted. thanks! :)\n' ;; @@ -258,7 +228,7 @@ case "$1" in printf 'welcome to the approval queue\n\n' - for user in /envs/pending-submissions/*; do + for user in /tilde/pending-submissions/*; do for scr in "$user"/*; do user="$(basename "$user")" script_name="$(basename "$scr")" @@ -268,11 +238,11 @@ case "$1" in cat "$scr"/description.txt prompt_confirm "approve?" || continue - sudo ln -s "$(readlink -f "$script")" /envs/bin/"$script_name" - sudo cp "$scr"/description.txt /envs/descriptions/"$script_name" + sudo ln -s "$(readlink -f "$script")" /tilde/bin/"$script_name" + sudo cp "$scr"/description.txt /tilde/descriptions/"$script_name" sudo touch "$scr"/approved - sudo chmod 664 /envs/descriptions/* - echo "your submission of $script_name has been approved and is now available at /envs/bin/$script_name" | /usr/sbin/sendmail "$user" + sudo chmod 664 /tilde/descriptions/* + echo "your submission of $script_name has been approved and is now available at /tilde/bin/$script_name" | /usr/sbin/sendmail "$user" done done echo "~~done for now~~" @@ -280,50 +250,24 @@ case "$1" in revoke) [[ "$(id -u)" != 0 ]] && error_exit "re-run this as sudo to access the revoke menu" - [[ -f /envs/bin/"$2" ]] || error_exit "$2 isn't an approved script" + [[ -f /tilde/bin/"$2" ]] || error_exit "$2 isn't an approved script" prompt_confirm "revoke $2?" printf 'please provide a reason: ' read -r reason - original_script="$(readlink -f /envs/bin/"$2")" + original_script="$(readlink -f /tilde/bin/"$2")" author="$(stat -c '%U' "$original_script")" - sudo rm /envs/{bin,descriptions}/"$2" - sudo rm -rf /envs/pending-submissions/"$author"/"$2" + sudo rm /tilde/{bin,descriptions}/"$2" + sudo rm -rf /tilde/pending-submissions/"$author"/"$2" echo -e "your script $2 has been returned because: $reason\nfeel free to resubmit" | /usr/sbin/sendmail "$author" printf '%s revoked and returned to author\n' "$2" ;; - - show) - cat "$INFO_FILE" - ;; - - edit) - if [[ -n "$EDITOR" ]]; then "$EDITOR" "$INFO_FILE"; else nano "INFO_FILE"; fi - ;; - - get) - sed -n "/^$2=/{s#^.*=##;p}" "$INFO_FILE" - ;; - - set) - if [ -z "$(cat < "$INFO_FILE" | sed -n /^"$2"=/p)" ]; then - echo "${2}=${3}" >> "$INFO_FILE" - else - sed -i "s#${2}=.*#${2}=${3}#" "$INFO_FILE" - fi - ;; - - unset) - sed -i "s#${2}=.*#${2}=#" "$INFO_FILE" - ;; - - *) - if [[ -f /envs/bin/"$1" ]]; then - prog=/envs/bin/"$1" + if [[ -x /tilde/bin/"$1" ]]; then + prog=/tilde/bin/"$1" shift $prog "$@" graceful_exit @@ -337,3 +281,4 @@ esac # graceful_exit + diff --git a/envs.1 b/tilde.1 similarity index 53% rename from envs.1 rename to tilde.1 index 30eab4d..fe2483d 100644 --- a/envs.1 +++ b/tilde.1 @@ -1,52 +1,52 @@ -.TH envs 1 "06 September 2019" "v0.0.4" +.TH tilde 1 "06 September 2019" "v0.0.4" .SH NAME -envs \- wrapper for user-submitted scripts and users_info.json entrys +tilde \- wrapper for user-submitted scripts and users_info.json entrys supports user settings, submission and admin approval .SH SYNOPSIS -.B envs [options] (scriptname) +.B tilde [options] (scriptname) .P .SH DESRIPTION -.B envs +.B tilde is a wrapper around user-submitted scripts. -any accepted script in /envs/bin can be run with +any accepted script in /tilde/bin can be run with the wrapper feature. users can submit any script in their ~/bin directory which will be mailed to admins for review. -users can also manage youre `users_info.json` entrys from the `~/.envs`-file. +users can also manage your `users_info.json` entries from the `~/.tilde`-file. .SH USAGE .TP -.B envs list -List all available scripts in /envs/bin +.B tilde list +List all available scripts in /tilde/bin .TP -.B envs [scriptname] +.B tilde [scriptname] Run scriptname. .TP -.B envs submit +.B tilde submit Submit a script from your ~/bin directory .TP -.B envs about [scriptname] +.B tilde about [scriptname] Get the submitter's description for a script. .TP -.B envs show +.B tilde show show your config file .TP -.B envs edit +.B tilde edit edit your config file .TP -.B envs get +.B tilde get show a entry from your config .TP -.B envs set <'value'> +.B tilde set <'value'> set a entry to your config .TP -.B envs unset +.B tilde unset unset a entry from your config .SH DEPENDENCIES None. .SH BUGS -None known. Please submit to https://git.envs.net/envs/envs_launcher/issues +None known. Please submit to https://github.com/tildeclub/launcher .SH AUTHOR Ben Harris