slish rev 11
Add slish to /etc/shells (used by dropbear) and some improvment
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon Jan 27 21:59:01 2014 +0100 (2014-01-27) |
parents | ab2bf5d509ef |
children | 7e9fc9556afe |
files | slish tools/slish.sh |
line diff
1.1 --- a/slish Sat Jan 25 00:19:41 2014 +0000 1.2 +++ b/slish Mon Jan 27 21:59:01 2014 +0100 1.3 @@ -70,6 +70,11 @@ 1.4 done 1.5 # Activity log must be writable by users 1.6 touch ${activity} && chmod 0666 ${activity} 1.7 + # Add /usr/bin/slish to /etc/shells (dropbear need it) 1.8 + if ! fgrep -q '/usr/bin/slish' /etc/shells; then 1.9 + echo "Adding /bin/slish to the list of valid shells..." 1.10 + echo '/usr/bin/slish' >> /etc/shells 1.11 + fi 1.12 echo "All done!" 1.13 } 1.14 1.15 @@ -116,7 +121,7 @@ 1.16 Content-Type: text/plain; charset=utf-8 1.17 Content-Transfer-Encoding: 8bit 1.18 1.19 -Hi, 1.20 +Hi $name, 1.21 1.22 Your custom SliTaz GNU/Linux SHell is ready to use! You can login with: 1.23 1.24 @@ -135,9 +140,18 @@ 1.25 1.26 # Add a new SliSH user 1.27 add_user() { 1.28 + #home="$root/./home/$user" 1.29 home="$root/home/$user" 1.30 shell="/usr/bin/slish" 1.31 1.32 + # Check values 1.33 + if [ ! "$user" ] || [ ! "$name" ] || [ ! "$pass" ] || [ ! "$mail" ]; then 1.34 + newline 1.35 + echo "Missing option(s): --user= --name= --pass= --mail=" 1.36 + newline && exit 0 1.37 + fi 1.38 + 1.39 + # Exit if user already exist 1.40 if grep -q ^${user}: /etc/passwd; then 1.41 newline 1.42 echo -n "User already exists: "; colorize 31 "$user" 1.43 @@ -146,7 +160,7 @@ 1.44 fi 1.45 1.46 newline 1.47 - echo -n "$(boldify 'Creating user:') "; colorize 32 "$user" 1.48 + echo -n "$(boldify 'Creating user:') "; colorize 34 "$user" 1.49 separator 1.50 echo -e "$pass\n$pass" | adduser -h "$home" -g "SliSH User" \ 1.51 -s ${shell} ${user} >/dev/null 1.52 @@ -185,6 +199,7 @@ 1.53 1.54 # Add all users from the signup queue 1.55 add_queued_user() { 1.56 + echo "Checking: $queue" 1.57 for user in $(ls ${queue}) 1.58 do 1.59 . ${queue}/${user}/account.conf 1.60 @@ -203,16 +218,16 @@ 1.61 newline && exit 0 1.62 fi 1.63 newline 1.64 - echo "$(boldify 'Deleting user:') $(colorize 32 "$user")" 1.65 + echo "$(boldify 'Deleting user:') $(colorize 34 "$user")" 1.66 separator 1.67 echo -n "Removing user account from $(hostname) server" 1.68 deluser "$user"; status 1.69 sed -i "/^$user:/"d ${root}/etc/passwd 1.70 sed -i "/^$user:/"d ${root}/etc/group 1.71 echo -n "Removing all files in : $home" 1.72 - rm -rf ${home} ; status 1.73 + rm -rf ${home}; status 1.74 echo -n "Removing user config : $people/$user" 1.75 - rm -rf "${people}/${user}" ; status 1.76 + rm -rf "${people}/${user}"; status 1.77 separator && newline 1.78 } 1.79 1.80 @@ -300,7 +315,7 @@ 1.81 adduser) 1.82 # We can adduser from cmdline or from the signup queue 1.83 check_root 1.84 - if [ "$from-queu" ]; then 1.85 + if [ "$queued" ]; then 1.86 add_queued_user 1.87 else 1.88 add_user 1.89 @@ -331,7 +346,7 @@ 1.90 . ${people}/"$USER"/account.conf 1.91 log "Chrooting user: $USER" 1.92 ulimit $(echo "$ULIMIT") 1.93 - exec chroot ${root} /bin/slish.sh "$@" 1.94 + exec /usr/sbin/chroot ${root} /bin/slish.sh "$@" 1.95 else 1.96 usage 1.97 fi ;;
2.1 --- a/tools/slish.sh Sat Jan 25 00:19:41 2014 +0000 2.2 +++ b/tools/slish.sh Mon Jan 27 21:59:01 2014 +0100 2.3 @@ -9,8 +9,11 @@ 2.4 . /lib/libtaz.sh 2.5 2.6 # Welcome 2.7 -clear && colorize 36 "Welcome to your SliTaz SHell" 2.8 -boldify $(date '+%a %b %d %Y - %H:%M') 2.9 +clear && boldify "Welcome to your SliTaz SHell" 2.10 +colorize 30 $(date '+%a %b %d %Y - %H:%M') 2.11 +newline 2.12 +echo "SliTaz : $(cat /etc/slitaz-release) ($(uname -sr))" 2.13 +echo "Home : $(du -sh /home/$USER)" 2.14 newline 2.15 2.16 # Set some env variables 2.17 @@ -18,8 +21,10 @@ 2.18 PATH='/bin:/usr/bin' 2.19 HOME=/home/$USER 2.20 SHELL=/bin/sh 2.21 -export PS1 PATH HOME SHELL 2.22 -umask 0077 2.23 +EDITOR=nano 2.24 +export PS1 PATH HOME SHELL EDITOR 2.25 +#umask 0077 2.26 +umask 0022 2.27 2.28 # Chroot will drop user into / 2.29 cd ${HOME}