Choose between normal user or root

This commit is contained in:
Sonny Bakker 2017-08-09 11:34:29 +02:00
parent a06ff298cd
commit 81a47408b7

View file

@ -8,7 +8,9 @@ if [ $EUID != 0 ]; then
fi fi
function get_path { function get_path {
# Get the full path of a file
SCRIPT=`realpath $0` SCRIPT=`realpath $0`
# Remove everything but the filename
SCRIPTPATH=`dirname $SCRIPT` SCRIPTPATH=`dirname $SCRIPT`
} }
@ -20,18 +22,29 @@ function user_config {
apt-get install -y curl apt-get install -y curl
fi fi
read -p 'Install the script for a normal user or root account? [user/root]: ' USER
if [[ "$USER" == "user" ]]; then
curl -fLo /home/$SUDO_USER/.vim/autoload/plug.vim --create-dirs \ curl -fLo /home/$SUDO_USER/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Create symlinks
get_path get_path
mkdir /home/$SUDO_USER/.vim ln -s $SCRIPTPATH/vim/{.vimrc,.tmux.conf} /home/$SUDO_USER/;
echo 'Creating systemlinks'
ln -s $SCRIPTPATH/vim/.vimrc /home/$SUDO_USER/;
ln -s $SCRIPTPATH/tmux/.tmux.conf /home/$SUDO_USER/;
ln -s $SCRIPTPATH/vim/colors /home/$SUDO_USER/.vim/ ln -s $SCRIPTPATH/vim/colors /home/$SUDO_USER/.vim/
chown -R $SUDO_USER:$SUDO_USER /home/$SUDO_USER/.vim chown -R $SUDO_USER:$SUDO_USER /home/$SUDO_USER/.vim
echo 'Linking configuration files done'
elif [[ "$USER" == "root" ]]; then
curl -fLo /root/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
get_path
ln -s $SCRIPTPATH/vim/{.vimrc,.tmux.conf} /root/
ln -s $SCRIPTPATH/vim/colors /root/.vim/
echo 'Linking configuration files done'
else
echo 'No selection was made'
exit 1
fi
} }
user_config user_config