mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-04-19 13:32:53 -05:00
Fixed installer for older versions
This commit is contained in:
parent
b2da704a09
commit
5f4008459c
1 changed files with 13 additions and 13 deletions
26
install.sh
26
install.sh
|
@ -5,7 +5,7 @@ originaldir=$PWD
|
||||||
environment=$(ps -o args= -p $$ | egrep -m 1 -o '\w{0,5}sh' | head -1)
|
environment=$(ps -o args= -p $$ | egrep -m 1 -o '\w{0,5}sh' | head -1)
|
||||||
if [ "$environment" = "bash" ] || [ "$environment" = "zsh" ];
|
if [ "$environment" = "bash" ] || [ "$environment" = "zsh" ];
|
||||||
then
|
then
|
||||||
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;
|
if ! grep -qs 'bash ~/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh ~/.welcome/welcome.sh' $zshrc && ! grep -qs 'bash /home/$USER/.welcome/welcome.sh' $bashrc && ! grep -qs 'zsh /home/$USER/.welcome/welcome.sh' $zshrc;
|
||||||
then
|
then
|
||||||
echo "Welcome! Installing in $environment..."
|
echo "Welcome! Installing in $environment..."
|
||||||
tput sc
|
tput sc
|
||||||
|
@ -76,16 +76,16 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# Check for older versions and replace bashrc lines #
|
# Check for older versions and replace bashrc lines #
|
||||||
if grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc ;
|
if grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc ;
|
||||||
then
|
then
|
||||||
line=$(grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc)
|
line=$(grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc)
|
||||||
line=${line%:*}
|
line=${line%:*}
|
||||||
sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc
|
sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc
|
||||||
echo 'bash ~/.welcome/welcome.sh' >> $bashrc
|
echo 'bash ~/.welcome/welcome.sh' >> $bashrc
|
||||||
fi
|
fi
|
||||||
if grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ;
|
if grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ;
|
||||||
then
|
then
|
||||||
line=$(grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc)
|
line=$(grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc)
|
||||||
line=${line%:*}
|
line=${line%:*}
|
||||||
sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc
|
sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc
|
||||||
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
||||||
|
@ -117,30 +117,30 @@ then
|
||||||
rm ~/.welcome/welcome.sh
|
rm ~/.welcome/welcome.sh
|
||||||
rm ~/.welcome/config.cfg
|
rm ~/.welcome/config.cfg
|
||||||
rmdir ~/.welcome
|
rmdir ~/.welcome
|
||||||
if grep -n 'bash ~/.welcome/welcome.sh' $bashrc ;
|
if grep -sn 'bash ~/.welcome/welcome.sh' $bashrc ;
|
||||||
then
|
then
|
||||||
line=$(grep -n 'bash ~/.welcome/welcome.sh' $bashrc)
|
line=$(grep -sn 'bash ~/.welcome/welcome.sh' $bashrc)
|
||||||
line=${line%:*}
|
line=${line%:*}
|
||||||
sed -i "${line}d" $bashrc
|
sed -i "${line}d" $bashrc
|
||||||
sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc
|
sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc
|
||||||
fi
|
fi
|
||||||
if grep -n 'zsh ~/.welcome/welcome.sh' $zshrc ;
|
if grep -sn 'zsh ~/.welcome/welcome.sh' $zshrc ;
|
||||||
then
|
then
|
||||||
line=$(grep -n 'zsh ~/.welcome/welcome.sh' $zshrc)
|
line=$(grep -sn 'zsh ~/.welcome/welcome.sh' $zshrc)
|
||||||
line=${line%:*}
|
line=${line%:*}
|
||||||
sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc
|
sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for older versions #
|
# Check for older versions #
|
||||||
if grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc ;
|
if grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc ;
|
||||||
then
|
then
|
||||||
line=$(grep -n 'bash /home/$USER/.welcome/welcome.sh' $bashrc)
|
line=$(grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc)
|
||||||
line=${line%:*}
|
line=${line%:*}
|
||||||
sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc
|
sed "${line}d" $bashrc > file.tmp && mv file.tmp $bashrc
|
||||||
fi
|
fi
|
||||||
if grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ;
|
if grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc ;
|
||||||
then
|
then
|
||||||
line=$(grep -n 'zsh /home/$USER/.welcome/welcome.sh' $zshrc)
|
line=$(grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc)
|
||||||
line=${line%:*}
|
line=${line%:*}
|
||||||
sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc
|
sed "${line}d" $zshrc > file.tmp && mv file.tmp $zshrc
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue