Working on non root usage

This commit is contained in:
Thomas Forgione 2019-04-16 13:46:58 +02:00
parent 7e8b2f3483
commit 22e1eccdd2
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7
1 changed files with 41 additions and 9 deletions

View File

@ -90,14 +90,24 @@ configure_zsh() {
test_command git test_command git
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
yes_no_ask_required "you'll need git for this, do you wish to install git ?" if [ $sudo_available -ne 0 ]; then
install git error "git is needed, but you don't have git neither sudo"
return 1
else
yes_no_ask_required "you'll need git for this, do you wish to install git ?"
install git
fi
fi fi
test_command zsh test_command zsh
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
yes_no_ask_required "this magnificent prompt is based on zsh, do you wish to install zsh ?" if [ $sudo_available -ne 0 ]; then
install zsh error "zsh is needed, but you don't have zsh neither sudo"
return 1
else
yes_no_ask_required "this magnificent prompt is based on zsh, do you wish to install zsh ?"
install zsh
fi
fi fi
mkdir -p $HOME/.config mkdir -p $HOME/.config
@ -131,12 +141,24 @@ configure_zsh() {
info "it seems that you already use zsh." info "it seems that you already use zsh."
else else
info "it seems your shell is not zsh..." info "it seems your shell is not zsh..."
yes_no_ask "do you want to change your shell ? (you'll need root) ?"
if [ $? -eq 0 ]; then if [ $sudo_available -eq 0 ]; then
info "changing your shell" # Sudo is available, run chsh
sudo chsh $user -s /bin/zsh yes_no_ask "do you want to change your shell ? (you'll need root) ?"
if [ $? -eq 0 ]; then
info "changing your shell"
sudo chsh $user -s /bin/zsh
else
info "not doing anything"
fi
else else
info "not doing anything" info "you don't have root, but you can run 'exec zsh' at the end of your bashrc"
yes_no_ask "do you wish to do that ?"
if [ $? -eq 0 ]; then
echo "\nexec zsh\n" >> $HOME/.bashrc
else
info "not doing anything"
fi
fi fi
fi fi
} }
@ -146,5 +168,15 @@ main() {
configure_zsh configure_zsh
} }
sudoresult=$(sudo -nv 2>&1)
if [ $? -eq 0 ]; then
sudo_available=0
elif echo $sudoresult | grep -q '^sudo:'; then
sudo_available=0
else
sudo_available=1
fi
main < /dev/tty main < /dev/tty