diff options
author | Alan Lacerda <alacerda@alpinelinux.org> | 2015-06-17 16:33:52 +0000 |
---|---|---|
committer | Alan Lacerda <alacerda@alpinelinux.org> | 2015-06-17 16:33:52 +0000 |
commit | a08555b0175e3481e03db90ed6caf5c4bed1ac09 (patch) | |
tree | e7a1e782ad6a519e44db61a2a8df655e0d3a8148 | |
parent | 9c02681869b3cdcbe577cd20c414291ff01d6c7f (diff) | |
download | setup-box-a08555b0175e3481e03db90ed6caf5c4bed1ac09.tar.bz2 setup-box-a08555b0175e3481e03db90ed6caf5c4bed1ac09.tar.xz |
setup-box: minor changes in usage and new option -u
-rwxr-xr-x | setup-box | 37 |
1 files changed, 23 insertions, 14 deletions
@@ -30,24 +30,26 @@ usage () { cat <<__EOF__ $(basename $0) $VERSION - Setup a variety Environments -Usage: $(basename $0) option [argument | desktop] +Usage: $(basename $0) option [args] Options: - -d Specify one of the following desktop environment: + -d Select a desktop environment: mate openbox xfce - -g Install a group (see -L) + -u create a user with the choosen username + If -d was set but -u was not, a default user will be created + -g group (see -G) + -s subgroup (see -S) -h Show this help - -L List all avaliable groups - -l List all avaliable subgroups - -s Install a subgroup (see -l) + -G List all avaliable groups + -S List all avaliable subgroups -v Show any error - just in case -V Show $(basename $0) version EXAMPLES: - Installing MATE Desktop, Internet applications and Pentest tools: - ~# $(basename $0) -d mate -s desktop_extras.internet -g pentest + Installing MATE Desktop for Jane with Internet applications and Pentest tools: + ~# $(basename $0) -d mate -u jane -s desktop_extras.internet -g pentest Installing a basic environment with Gparted: ~# $(basename $0) -d openbox -s systools.disk @@ -58,7 +60,7 @@ __EOF__ # Installing all dependencies for setup-box. check_deps() { - if [ "$(whoami)" != "root" ]; then + if [ "$(id -u)" != "0" ]; then cat <<__EOF__ *********************************** **** WARNING: You are not root **** @@ -302,7 +304,7 @@ main () { search_files # If there is any argument... let's work - while getopts "d:s:g:hLlvV" opt ; do + while getopts "d:s:g:u:hGSvV" opt ; do case $opt in d) create_user="1" @@ -312,10 +314,12 @@ main () { search_sub_group "$OPTARG";; g) search_meta_group "$OPTARG";; - L) + G) list_meta_groups;; - l) + S) list_sub_groups;; + u) + new_user="$OPTARG";; v) show_error="1";; V) @@ -332,14 +336,16 @@ main () { # Packages to be installed (including services) optimize_pack "$final_pack" - apk add $final_pack + apk add --virtual .setup-box $final_pack # Services to be added to startup (just services) optimize_serv "$final_serv" add_services $final_serv if [ "$create_user" == "1" ]; then - new_user="alpine" + if [ "x$new_user" == "x" ]; then + new_user="alpine" + fi echo -e "\033[1;33m****************************************************" echo -e "We've created a new user for you: $new_user" echo -e "****************************************************" @@ -348,6 +354,9 @@ main () { echo -e "\033[0;31mPasswords mismatch. Try again" passwd $new_user done + for grp in audio video cdrom usb; do + adduser $new_user $grp + done echo -e "\033[0m" fi |