rename to tilde

This commit is contained in:
Ben Harris 2019-09-22 15:03:24 -04:00
parent 612b194bc7
commit c3bbf342f1
4 changed files with 73 additions and 126 deletions

View File

@ -1,4 +1,4 @@
BASENAME ?= envs BASENAME ?= tilde
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man MANDIR ?= $(PREFIX)/share/man

View File

@ -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) 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 wrapper for user-submitted scripts and users_info.json entrys
@ -8,26 +9,27 @@ supports user settings, submission and admin approval
User Scripts User Scripts
usage: envs [help|list|submit|about|script_name] usage: tilde [help|list|submit|about|script_name]
envs list - show a list of approved userscripts tilde list - show a list of approved userscripts
envs submit - start the submission flow for your own script tilde submit - start the submission flow for your own script
envs about <script_name> - get the description for script_name tilde about <script_name> - get the description for script_name
envs <script_name> - run script_name with all remaining args are passed to the script tilde <script_name> - run script_name with all remaining args are passed to the script
User json-File Infomations User json-File Infomations
usage: envs [show]|[edit]|[get name]|[set name value]|[unset name] usage: tilde [show]|[edit]|[get name]|[set name value]|[unset name]
envs show - show your config file tilde show - show your config file
envs edit - edit your config file tilde edit - edit your config file
envs get <entry> - show a entry from your config tilde get <entry> - show a entry from your config
envs set <entry> <'value'> - set a entry to your config tilde set <entry> <'value'> - set a entry to your config
envs unset <entry> - unset a entry from your config tilde unset <entry> - 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. submissions use sendmail to notify an admin.
admins can use `sudo envs approve` and `sudo envs revoke <script_name>`. admins can use `sudo tilde approve` and `sudo tilde revoke <script_name>`.
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.

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# envs - manage users_info.json entrys and user-submitted scripts # tilde - manage user-submitted scripts
# forked from tilde.team # forked from tilde.team
# Copyright 2018-2019, Ben Harris <ben@tilde.team> # Copyright 2018-2019, Ben Harris <ben@tilde.team>
@ -17,7 +17,7 @@
# GNU General Public License at <http://www.gnu.org/licenses/> for # GNU General Public License at <http://www.gnu.org/licenses/> for
# more details. # more details.
# Usage: envs [-h|--help] # Usage: tilde [-h|--help]
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
export TERM=xterm-256color export TERM=xterm-256color
@ -25,7 +25,7 @@ export TERM=xterm-256color
PROGNAME=${0##*/} PROGNAME=${0##*/}
VERSION="0.0.5" 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" printf ' %s submit - start the submission flow for your own script\n' "$PROGNAME"
[[ $(id -u) == 0 ]] && { [[ $(id -u) == 0 ]] && {
printf ' %s approve - enter the approval queue\n' "$PROGNAME" printf ' %s approve - enter the approval queue\n' "$PROGNAME"
printf ' %s revoke <script_name> - send a script back to the author and remove from /envs/bin\n' "$PROGNAME" printf ' %s revoke <script_name> - send a script back to the author and remove from /tilde/bin\n' "$PROGNAME"
} }
printf ' %s about <script_name> - get the description for script_name\n' "$PROGNAME" printf ' %s about <script_name> - get the description for script_name\n' "$PROGNAME"
printf ' %s <script_name> - run script_name with all remaining args are passed to the script\n' "$PROGNAME" printf ' %s <script_name> - 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)" if [[ :$PATH: != *:"/tilde/bin":* ]] ; then
printf '\nusage: %s [show]|[edit]|[get name]|[set name value]|[unset name]\n' "$PROGNAME" printf "\nadd /tilde/bin to your PATH to use approved scripts without this wrapper\n"
printf ' %s show - show your config file\n' "$PROGNAME"
printf ' %s edit - edit your config file\n' "$PROGNAME"
printf ' %s get <entry> - show a entry from your config\n' "$PROGNAME"
printf " %s set <entry> <'value'> - set a entry to your config\n" "$PROGNAME"
printf ' %s unset <entry> - 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"
printf "if you're using bash, run the following to add it quickly\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 fi
} }
@ -103,7 +95,7 @@ usage() {
help_message() { help_message() {
cat <<- EOF cat <<- EOF
$(tput setaf 6)$PROGNAME (ver. $VERSION)$(tput sgr0) $(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 supports user settings, submission and admin approval
$(usage) $(usage)
EOF EOF
@ -116,10 +108,10 @@ verify_script_name() {
if [[ "$(type "$1" > /dev/null 2>&1)" ]]; then if [[ "$(type "$1" > /dev/null 2>&1)" ]]; then
error_exit "$1 already exists. rename your script and try again." error_exit "$1 already exists. rename your script and try again."
fi 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 case "$1" in
help|about|description|desc|list|ls|submit|apropos|approve|revoke|show|edit|get|set|unset) help|about|description|desc|list|ls|submit|apropos|approve|revoke|show)
error_exit "$1 is a subcommand of envs. rename your script and try again.";; error_exit "$1 is a subcommand of tilde. rename your script and try again.";;
*) *)
return;; return;;
esac esac
@ -141,11 +133,11 @@ EOF
mail_body() { mail_body() {
cat <<- EOF cat <<- EOF
Subject: envs script submission from $USER Subject: tilde script submission from $USER
From: $USER@envs.net From: $USER@tilde.club
To: creme@envs.net To: root@tilde.club
envs script submission from $USER tilde script submission from $USER
script name: $1 script name: $1
@ -155,35 +147,13 @@ description:
$2 $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: run this to see the approval queue:
sudo envs approve sudo tilde approve
EOF 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 signals
trap "signal_exit TERM" TERM HUP trap "signal_exit TERM" TERM HUP
trap "signal_exit INT" INT trap "signal_exit INT" INT
@ -207,18 +177,18 @@ case "$1" in
list | ls) list | ls)
printf 'available scripts:\n\n' printf 'available scripts:\n\n'
for scr in /envs/bin/*; do for scr in /tilde/bin/*; do
script_name=$(basename "$scr") script_name=$(basename "$scr")
target=$(readlink -f "$scr") target=$(readlink -f "$scr")
printf '%s%s by %s%s\n' "$(tput setaf 6)" "$script_name" "$(stat -c '%U' "$target")" "$(tput sgr0)" 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' printf '\n'
done done
;; ;;
about | apropos | description | desc) about | apropos | description | desc)
if [[ -f /envs/descriptions/"$2" ]]; then if [[ -f /tilde/descriptions/"$2" ]]; then
cat /envs/descriptions/"$2" cat /tilde/descriptions/"$2"
else else
printf '%s not found. try %s list to see available user scripts.\n' "$2" "$PROGNAME" printf '%s not found. try %s list to see available user scripts.\n' "$2" "$PROGNAME"
fi fi
@ -235,7 +205,7 @@ case "$1" in
if [[ -x "$HOME"/bin/"$script_name" ]]; then if [[ -x "$HOME"/bin/"$script_name" ]]; then
printf '\ncool, found your script\n' 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 else
error_exit "$script_name not found in ~/bin" error_exit "$script_name not found in ~/bin"
fi fi
@ -246,10 +216,10 @@ case "$1" in
prompt_confirm "ready to submit?" || graceful_exit prompt_confirm "ready to submit?" || graceful_exit
# submit now # submit now
mkdir -p /envs/pending-submissions/"$USER"/"$script_name" mkdir -p /tilde/pending-submissions/"$USER"/"$script_name"
ln -s "$HOME"/bin/"$script_name" /envs/pending-submissions/"$USER"/"$script_name"/"$script_name" ln -s "$HOME"/bin/"$script_name" /tilde/pending-submissions/"$USER"/"$script_name"/"$script_name"
echo "$description" > /envs/pending-submissions/"$USER"/"$script_name"/description.txt echo "$description" > /tilde/pending-submissions/"$USER"/"$script_name"/description.txt
mail_body "$script_name" "$description" | /usr/sbin/sendmail creme mail_body "$script_name" "$description" | /usr/sbin/sendmail root
printf 'script submitted. thanks! :)\n' printf 'script submitted. thanks! :)\n'
;; ;;
@ -258,7 +228,7 @@ case "$1" in
printf 'welcome to the approval queue\n\n' 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 for scr in "$user"/*; do
user="$(basename "$user")" user="$(basename "$user")"
script_name="$(basename "$scr")" script_name="$(basename "$scr")"
@ -268,11 +238,11 @@ case "$1" in
cat "$scr"/description.txt cat "$scr"/description.txt
prompt_confirm "approve?" || continue prompt_confirm "approve?" || continue
sudo ln -s "$(readlink -f "$script")" /envs/bin/"$script_name" sudo ln -s "$(readlink -f "$script")" /tilde/bin/"$script_name"
sudo cp "$scr"/description.txt /envs/descriptions/"$script_name" sudo cp "$scr"/description.txt /tilde/descriptions/"$script_name"
sudo touch "$scr"/approved sudo touch "$scr"/approved
sudo chmod 664 /envs/descriptions/* sudo chmod 664 /tilde/descriptions/*
echo "your submission of $script_name has been approved and is now available at /envs/bin/$script_name" | /usr/sbin/sendmail "$user" echo "your submission of $script_name has been approved and is now available at /tilde/bin/$script_name" | /usr/sbin/sendmail "$user"
done done
done done
echo "~~done for now~~" echo "~~done for now~~"
@ -280,50 +250,24 @@ case "$1" in
revoke) revoke)
[[ "$(id -u)" != 0 ]] && error_exit "re-run this as sudo to access the revoke menu" [[ "$(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?" prompt_confirm "revoke $2?"
printf 'please provide a reason: ' printf 'please provide a reason: '
read -r reason read -r reason
original_script="$(readlink -f /envs/bin/"$2")" original_script="$(readlink -f /tilde/bin/"$2")"
author="$(stat -c '%U' "$original_script")" author="$(stat -c '%U' "$original_script")"
sudo rm /envs/{bin,descriptions}/"$2" sudo rm /tilde/{bin,descriptions}/"$2"
sudo rm -rf /envs/pending-submissions/"$author"/"$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" 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" 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 if [[ -x /tilde/bin/"$1" ]]; then
prog=/envs/bin/"$1" prog=/tilde/bin/"$1"
shift shift
$prog "$@" $prog "$@"
graceful_exit graceful_exit
@ -337,3 +281,4 @@ esac
# #
graceful_exit graceful_exit

View File

@ -1,52 +1,52 @@
.TH envs 1 "06 September 2019" "v0.0.4" .TH tilde 1 "06 September 2019" "v0.0.4"
.SH NAME .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 supports user settings, submission and admin approval
.SH SYNOPSIS .SH SYNOPSIS
.B envs [options] (scriptname) .B tilde [options] (scriptname)
.P .P
.SH DESRIPTION .SH DESRIPTION
.B envs .B tilde
is a wrapper around user-submitted scripts. 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. the wrapper feature.
users can submit any script in their ~/bin directory users can submit any script in their ~/bin directory
which will be mailed to admins for review. 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 .SH USAGE
.TP .TP
.B envs list .B tilde list
List all available scripts in /envs/bin List all available scripts in /tilde/bin
.TP .TP
.B envs [scriptname] .B tilde [scriptname]
Run scriptname. Run scriptname.
.TP .TP
.B envs submit .B tilde submit
Submit a script from your ~/bin directory Submit a script from your ~/bin directory
.TP .TP
.B envs about [scriptname] .B tilde about [scriptname]
Get the submitter's description for a script. Get the submitter's description for a script.
.TP .TP
.B envs show .B tilde show
show your config file show your config file
.TP .TP
.B envs edit .B tilde edit
edit your config file edit your config file
.TP .TP
.B envs get <entry> .B tilde get <entry>
show a entry from your config show a entry from your config
.TP .TP
.B envs set <entry> <'value'> .B tilde set <entry> <'value'>
set a entry to your config set a entry to your config
.TP .TP
.B envs unset <entry> .B tilde unset <entry>
unset a entry from your config unset a entry from your config
.SH DEPENDENCIES .SH DEPENDENCIES
None. None.
.SH BUGS .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 .SH AUTHOR
Ben Harris <ben (at) tilde (dot) team> Ben Harris <ben (at) tilde (dot) team>