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,15 +90,25 @@ configure_zsh() {
test_command git
if [ $? -ne 0 ]; then
if [ $sudo_available -ne 0 ]; then
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
test_command zsh
if [ $? -ne 0 ]; then
if [ $sudo_available -ne 0 ]; then
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
mkdir -p $HOME/.config
if [ ! -d $HOME/.config/oh-my-zsh ]; then
@ -131,6 +141,9 @@ configure_zsh() {
info "it seems that you already use zsh."
else
info "it seems your shell is not zsh..."
if [ $sudo_available -eq 0 ]; then
# Sudo is available, run chsh
yes_no_ask "do you want to change your shell ? (you'll need root) ?"
if [ $? -eq 0 ]; then
info "changing your shell"
@ -138,6 +151,15 @@ configure_zsh() {
else
info "not doing anything"
fi
else
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
}
@ -146,5 +168,15 @@ main() {
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