#!/bin/sh # --------------------------------------------------------------------------- # tilde - manage user-submitted scripts and apps # Copyright 2018, Ben Harris # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License at for # more details. # Usage: tilde [-h|--help] # --------------------------------------------------------------------------- PROGNAME=${0##*/} VERSION="0.1.0" user=$(whoami) hostname=$(hostname -f) # check coreutils and wrap stat for portability if stat -c"%U" /dev/null >/dev/null 2>/dev/null ; then # GNU environment stat_func () { stat -c '%U' "$1" } else # BSD environment stat_func () { stat -f %Su "$1" } fi isroot() { [ "$(id -u)" = "0" ] } error_exit() { printf "%s\n" "${1:-"unknown Error"}" >&2 exit 1 } signal_exit() { # Handle trapped signals case $1 in INT) error_exit "program interrupted by user" ;; TERM) printf "\n%s: program terminated" "$PROGNAME" >&2 exit ;; *) error_exit "$PROGNAME: terminating on unknown signal" ;; esac } prompt_confirm() { while true; do printf "%s [y/n]: " "${1:-continue?}" read -r REPLY case $REPLY in [yY]) printf "\n" ; return 0 ;; [nN]) printf "\n" ; return 1 ;; *) printf " \033[31m %s \n\033[0m" "invalid input" ;; esac done } help_message() { cat <<-EOF Usage: $PROGNAME [options] [command] Options: -h, --help Show this help message and exit -v, --version Show version information Commands: list Show a list of approved user scripts submit Start the submission flow for your own script about