forked from team/tilde-launcher
check for file, not executable for arg not found
This commit is contained in:
parent
e7080f8209
commit
47185a2df4
66
tilde
66
tilde
|
@ -67,7 +67,16 @@ prompt_confirm() {
|
||||||
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo -e "usage: $PROGNAME [help|list|submit|about|script_name]"
|
echo -e "\nusage: $PROGNAME [help|list|submit|about|script_name]\n"
|
||||||
|
echo " $PROGNAME list - show a list of approved userscripts"
|
||||||
|
echo " $PROGNAME submit - start the submission flow for your own script"
|
||||||
|
[[ $(id -u) == 0 ]] && {
|
||||||
|
echo " $PROGNAME approve - enter the approval queue"
|
||||||
|
echo " $PROGNAME revoke <script_name> - send a script back to the author and remove from /tilde/bin"
|
||||||
|
}
|
||||||
|
echo " $PROGNAME about <script_name> - get the description for script_name"
|
||||||
|
echo " $PROGNAME <script_name> - run script_name with all remaining args are passed to the script"
|
||||||
|
|
||||||
if [[ :$PATH: != *:"/tilde/bin":* ]] ; then
|
if [[ :$PATH: != *:"/tilde/bin":* ]] ; then
|
||||||
echo -e "\nadd /tilde/bin to your PATH to use approved scripts without this wrapper"
|
echo -e "\nadd /tilde/bin to your PATH to use approved scripts without this wrapper"
|
||||||
echo "if you're using bash, run the following to add it quickly"
|
echo "if you're using bash, run the following to add it quickly"
|
||||||
|
@ -79,21 +88,37 @@ usage() {
|
||||||
help_message() {
|
help_message() {
|
||||||
cat <<- _EOF_
|
cat <<- _EOF_
|
||||||
$PROGNAME ver. $VERSION
|
$PROGNAME ver. $VERSION
|
||||||
manage user-submitted scripts and apps
|
wrapper for user-submitted scripts
|
||||||
|
supports user submission and admin approval
|
||||||
$(usage)
|
$(usage)
|
||||||
_EOF_
|
_EOF_
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
verify_script_name() {
|
||||||
|
[[ $1 == "" ]] && error_exit "please start over and enter the script name"
|
||||||
|
[[ $(type -P "$1") ]] &&
|
||||||
|
[[ -x $HOME/bin/$1 ]] ||
|
||||||
|
error_exit "$1 already exists. 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
|
||||||
|
about|description|list|ls|submit|about|help|apropos|submit|approve)
|
||||||
|
error_exit "$1 is a subcommand of tilde. rename your script and try again." ;;
|
||||||
|
*)
|
||||||
|
return ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
submission_checklist() {
|
submission_checklist() {
|
||||||
cat <<- _EOF_
|
cat <<- _EOF_
|
||||||
requirements for submitting a user script or program:
|
requirements for submitting a user script or program:
|
||||||
|
|
||||||
- placed in your ~/bin
|
- placed in your ~/bin
|
||||||
- executable
|
- executable
|
||||||
- responds to help, -h, and --help
|
- responds to help or --help
|
||||||
|
- no name collisions with existing scripts or $PROGNAME subcommands
|
||||||
|
|
||||||
_EOF_
|
_EOF_
|
||||||
}
|
}
|
||||||
|
@ -167,6 +192,8 @@ case $1 in
|
||||||
echo -n "enter the name of your script: "
|
echo -n "enter the name of your script: "
|
||||||
read script_name
|
read script_name
|
||||||
|
|
||||||
|
verify_script_name $script_name
|
||||||
|
|
||||||
if [[ -x $HOME/bin/$script_name ]]; then
|
if [[ -x $HOME/bin/$script_name ]]; then
|
||||||
echo "cool, found your script"
|
echo "cool, found your script"
|
||||||
[[ -x /tilde/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"
|
||||||
|
@ -187,9 +214,7 @@ case $1 in
|
||||||
echo "script submitted. thanks! :)" ;;
|
echo "script submitted. thanks! :)" ;;
|
||||||
|
|
||||||
approve)
|
approve)
|
||||||
if [[ $(id -u) != 0 ]]; then
|
[[ $(id -u) != 0 ]] && error_exit "re-run this as sudo to access the approval queue"
|
||||||
error_exit "You must be the superuser to run this script."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "welcome to the approval queue\n\n"
|
echo -e "welcome to the approval queue\n\n"
|
||||||
|
|
||||||
|
@ -197,20 +222,39 @@ case $1 in
|
||||||
for scr in $user/*; do
|
for scr in $user/*; do
|
||||||
user=$(basename $user)
|
user=$(basename $user)
|
||||||
script_name=$(basename $scr)
|
script_name=$(basename $scr)
|
||||||
|
[[ -f $scr/approved ]] && continue
|
||||||
script=$scr/$script_name
|
script=$scr/$script_name
|
||||||
echo "$script_name by $user"
|
echo "$script_name by $user"
|
||||||
cat $scr/description.txt
|
cat $scr/description.txt
|
||||||
prompt_confirm "approve?" || continue
|
prompt_confirm "approve?" || continue
|
||||||
|
|
||||||
sudo ln -s $(readlink -f $script) /tilde/bin/$script_name
|
sudo ln -s $(readlink -f $script) /tilde/bin/$script_name
|
||||||
sudo mv $scr/description.txt /tilde/descriptions/$script_name
|
sudo cp $scr/description.txt /tilde/descriptions/$script_name
|
||||||
sudo rm -rf $scr
|
sudo touch $scr/approved
|
||||||
|
sudo chmod 664 /tilde/descriptions/*
|
||||||
echo "your submission of $script_name has been approved and is now available at /tilde/bin/$script_name" | sendmail $user
|
echo "your submission of $script_name has been approved and is now available at /tilde/bin/$script_name" | sendmail $user
|
||||||
done
|
done
|
||||||
done ;;
|
done
|
||||||
|
echo "~~done for now~~" ;;
|
||||||
|
|
||||||
|
revoke)
|
||||||
|
[[ $(id -u) != 0 ]] && error_exit "re-run this as sudo to access the revoke menu"
|
||||||
|
[[ -f /tilde/bin/$2 ]] || error_exit "$2 isn't an approved script"
|
||||||
|
|
||||||
|
prompt_confirm "revoke $2?"
|
||||||
|
echo -n "please provide a reason: "
|
||||||
|
read reason
|
||||||
|
|
||||||
|
original_script=$(readlink -f /tilde/bin/$2)
|
||||||
|
author=$(stat -c '%U' $original_script)
|
||||||
|
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" | sendmail $author
|
||||||
|
echo "$2 revoked and returned to author" ;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
if [[ -x /tilde/bin/$1 ]]; then
|
if [[ -f /tilde/bin/$1 ]]; then
|
||||||
prog=/tilde/bin/$1
|
prog=/tilde/bin/$1
|
||||||
shift
|
shift
|
||||||
$prog "$@"
|
$prog "$@"
|
||||||
|
|
Loading…
Reference in New Issue