install.sh: differentiate processing for root, check for sudo before calling it, and add support for ponctual user definition
This commit is contained in:
parent
9dd4463d45
commit
359af900d1
34
install.sh
34
install.sh
@ -2,15 +2,33 @@
|
|||||||
|
|
||||||
run_directory=$(dirname "$0")
|
run_directory=$(dirname "$0")
|
||||||
|
|
||||||
echo "Copying rcs to home directory..."
|
if [ -z "$1" ]; then
|
||||||
cp $run_directory/bashrc /home/$(whoami)/.bashrc
|
user=$(whoami)
|
||||||
cp $run_directory/vimrc /home/$(whoami)/.vimrc
|
else
|
||||||
cp $run_directory/tmux.conf /home/$(whoami)/.tmux.conf
|
user=$1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Copying rcs to root directory..."
|
if [[ $user != 'root' ]]; then
|
||||||
sudo cp $run_directory/bashrc /root/.bashrc
|
echo "Copying rcs to home directory..."
|
||||||
sudo cp $run_directory/vimrc /root/.vimrc
|
cp $run_directory/bashrc /home/$user/.bashrc
|
||||||
sudo cp $run_directory/tmux.conf /root/.tmux.conf
|
cp $run_directory/vimrc /home/$user/.vimrc
|
||||||
|
cp $run_directory/tmux.conf /home/$user/.tmux.conf
|
||||||
|
|
||||||
|
if ! command -v sudo &> /dev/null; then
|
||||||
|
echo "Could not copy to root directory: sudo was not found."
|
||||||
|
else
|
||||||
|
echo "Copying rcs to root directory..."
|
||||||
|
sudo cp $run_directory/bashrc /root/.bashrc
|
||||||
|
sudo cp $run_directory/vimrc /root/.vimrc
|
||||||
|
sudo cp $run_directory/tmux.conf /root/.tmux.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Copying rcs to root directory..."
|
||||||
|
cp $run_directory/bashrc /root/.bashrc
|
||||||
|
cp $run_directory/vimrc /root/.vimrc
|
||||||
|
cp $run_directory/tmux.conf /root/.tmux.conf
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Finished install. Exiting..."
|
echo "Finished install. Exiting..."
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user