mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-04-19 05:22:53 -05:00
Made install use proper home directory
This commit is contained in:
parent
a6b5f4ded8
commit
b5060b4658
1 changed files with 27 additions and 12 deletions
39
install.sh
39
install.sh
|
@ -1,34 +1,34 @@
|
|||
version=0.2.5
|
||||
bashrc="/home/$USER/.bashrc"
|
||||
zshrc="/home/$USER/.zshrc"
|
||||
bashrc=~/.bashrc
|
||||
zshrc=~/.zshrc
|
||||
originaldir=$PWD
|
||||
environment=$(ps -o args= -p $$ | egrep -m 1 -o '\w{0,5}sh' | head -1)
|
||||
if [ "$environment" = "bash" ] || [ "$environment" = "zsh" ];
|
||||
then
|
||||
if ! grep -q 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -q 'zsh /home/$USER/.welcome/welcome.sh' $zshrc;
|
||||
if ! grep -q 'bash ~/.welcome/welcome.sh' $bashrc && ! grep -q 'zsh ~/.welcome/welcome.sh' $zshrc && ! grep -q 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -q 'zsh /home/$USER/.welcome/welcome.sh' $zshrc;
|
||||
then
|
||||
echo "Welcome! Installing in $environment..."
|
||||
tput sc
|
||||
cd /home/$USER
|
||||
mkdir -p /home/$USER/.welcome
|
||||
cd ~/
|
||||
mkdir -p ~/.welcome
|
||||
if which curl >/dev/null ;
|
||||
then
|
||||
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --output /home/$USER/.welcome/welcome.sh
|
||||
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --output ~/.welcome/welcome.sh
|
||||
elif which wget >/dev/null ;
|
||||
then
|
||||
wget https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --P /home/$USER/.welcome/
|
||||
wget https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --P ~/.welcome/
|
||||
else
|
||||
echo "Cannot download, neither wget nor curl is available."
|
||||
exit 1
|
||||
fi
|
||||
chmod +x /home/$USER/.welcome/welcome.sh
|
||||
chmod +x ~/.welcome/welcome.sh
|
||||
if [[ "$environment" = "bash" ]];
|
||||
then
|
||||
echo 'bash /home/$USER/.welcome/welcome.sh' >> $bashrc
|
||||
echo 'bash ~/.welcome/welcome.sh' >> $bashrc
|
||||
echo "Installing to bashrc"
|
||||
elif [[ "$environment" = "zsh" ]];
|
||||
then
|
||||
echo 'zsh /home/$USER/.welcome/welcome.sh' >> $zshrc
|
||||
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
||||
echo "Installing to zshrc"
|
||||
fi
|
||||
cd "$originaldir"
|
||||
|
@ -51,8 +51,22 @@ then
|
|||
tput rc el ed
|
||||
echo "Goodbye. Uninstalling..."
|
||||
tput sc
|
||||
rm /home/$USER/.welcome/welcome.sh
|
||||
rmdir /home/$USER/.welcome
|
||||
rm ~/.welcome/welcome.sh
|
||||
rmdir ~/.welcome
|
||||
if grep -n 'bash ~/.welcome/welcome.sh' $bashrc ;
|
||||
then
|
||||
line=$(grep -n 'bash ~/.welcome/welcome.sh' $bashrc)
|
||||
line=${line%:*}
|
||||
sed -i "${line}d" $bashrc
|
||||
fi
|
||||
if grep -n 'zsh ~/.welcome/welcome.sh' $zshrc ;
|
||||
then
|
||||
line=$(grep -n 'zsh ~/.welcome/welcome.sh' $zshrc)
|
||||
line=${line%:*}
|
||||
sed -i "${line}d" $zshrc
|
||||
fi
|
||||
|
||||
# Check for older versions #
|
||||
if grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc ;
|
||||
then
|
||||
line=$(grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc)
|
||||
|
@ -65,6 +79,7 @@ then
|
|||
line=${line%:*}
|
||||
sed -i "${line}d" $zshrc
|
||||
fi
|
||||
|
||||
tput rc el ed
|
||||
echo -e "\e[36mUninstalled! \e[0m"
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue