Revert "install.sh: adapt behviour when calling with argument"
This reverts commit 8a253e1090
.
This commit is contained in:
parent
8a253e1090
commit
d8c16a134a
@ -8,4 +8,4 @@ This repository contains setup or config files for generic CLI applications, suc
|
|||||||
* `tmux.conf` is tmux config file and should be installed at `~/.tmux.conf`.
|
* `tmux.conf` is tmux config file and should be installed at `~/.tmux.conf`.
|
||||||
#### Installation
|
#### Installation
|
||||||
* `install.sh` script copies above files to their respective destinations;
|
* `install.sh` script copies above files to their respective destinations;
|
||||||
* can be called with an argument, which will be used as user name (to be used with setup scripts).
|
* can be called with an argument, which will be used as user name.
|
||||||
|
38
install.sh
38
install.sh
@ -4,32 +4,26 @@ run_directory=$(dirname "$0")
|
|||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
user=$(whoami)
|
user=$(whoami)
|
||||||
if [[ $user != 'root' ]]; then
|
else
|
||||||
echo "Copying rcs to home directory..."
|
user=$1
|
||||||
cp $run_directory/bashrc /home/$user/.bashrc
|
fi
|
||||||
cp $run_directory/vimrc /home/$user/.vimrc
|
|
||||||
cp $run_directory/tmux.conf /home/$user/.tmux.conf
|
if [[ $user != 'root' ]]; then
|
||||||
if ! command -v sudo &> /dev/null; then
|
echo "Copying rcs to home directory..."
|
||||||
echo "Could not copy to root directory: sudo was not found."
|
cp $run_directory/bashrc /home/$user/.bashrc
|
||||||
else
|
cp $run_directory/vimrc /home/$user/.vimrc
|
||||||
echo "Copying rcs to root directory..."
|
cp $run_directory/tmux.conf /home/$user/.tmux.conf
|
||||||
sudo cp $run_directory/bashrc /root/.bashrc
|
|
||||||
sudo cp $run_directory/vimrc /root/.vimrc
|
if ! command -v sudo &> /dev/null; then
|
||||||
sudo cp $run_directory/tmux.conf /root/.tmux.conf
|
echo "Could not copy to root directory: sudo was not found."
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "Copying rcs to root directory..."
|
echo "Copying rcs to root directory..."
|
||||||
cp $run_directory/bashrc /root/.bashrc
|
sudo cp $run_directory/bashrc /root/.bashrc
|
||||||
cp $run_directory/vimrc /root/.vimrc
|
sudo cp $run_directory/vimrc /root/.vimrc
|
||||||
cp $run_directory/tmux.conf /root/.tmux.conf
|
sudo cp $run_directory/tmux.conf /root/.tmux.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else # running from a setup script, assuming as root
|
else
|
||||||
user=$1
|
|
||||||
echo "Copying rcs to home directory..."
|
|
||||||
sudo -H -u $user cp $run_directory/bashrc /home/$user/.bashrc
|
|
||||||
sudo -H -u $user cp $run_directory/vimrc /home/$user/.vimrc
|
|
||||||
sudo -H -u $user cp $run_directory/tmux.conf /home/$user/.tmux.conf
|
|
||||||
echo "Copying rcs to root directory..."
|
echo "Copying rcs to root directory..."
|
||||||
cp $run_directory/bashrc /root/.bashrc
|
cp $run_directory/bashrc /root/.bashrc
|
||||||
cp $run_directory/vimrc /root/.vimrc
|
cp $run_directory/vimrc /root/.vimrc
|
||||||
|
Loading…
Reference in New Issue
Block a user