Compare commits

..

No commits in common. "9cee7f290455dc4ef8cda688197cbc81d489395e" and "e82a0cf000d36dbc4452bd9dcd3f3d81a3165083" have entirely different histories.

View file

@ -58,12 +58,15 @@ uninstall () {
} }
update () { update () {
# To monitor number of downloads/updates
curl https://g2games.dev/Assets/counter/counter.php
tput rc el ed tput rc el ed
echo "Updating..." echo "Updating..."
tput sc tput sc
mkdir -p ~/.welcome mkdir -p ~/.welcome
rm ~/.welcome/welcome.sh 2> /dev/null rm ~/.welcome/welcome.sh
rm ~/.welcome/install.sh 2> /dev/null rm ~/.welcome/install.sh
curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/welcome.sh --output ~/.welcome/welcome.sh curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v"${version}"/welcome.sh --output ~/.welcome/welcome.sh
curl -SL https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh --output ~/.welcome/install.sh curl -SL https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh --output ~/.welcome/install.sh
@ -74,19 +77,19 @@ update () {
fi fi
# Check for older versions and replace bashrc lines # Check for older versions and replace bashrc lines
lines=$(grep -sn 'bash ~/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g' && grep -sn 'bash /home/$USER/.welcome/welcome.sh' "$bashrc" | sed -e 's/:.*//g') # Find target line number lines=$(grep -sn 'bash ~/.welcome/welcome.sh' $bashrc | sed -e 's/:.*//g' && grep -sn 'bash /home/$USER/.welcome/welcome.sh' $bashrc | sed -e 's/:.*//g')
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g') # Format the line number properly (macos doesn't have Cut)
for i in $lines; do
sed "${i}d" "$bashrc" > file.tmp && mv file.tmp "$bashrc"
done
echo 'bash ~/.welcome/welcome.sh' >> "$bashrc"
lines=$(grep -sn 'zsh ~/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g' && grep -sn 'zsh /home/$USER/.welcome/welcome.sh' "$zshrc" | sed -e 's/:.*//g')
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g') lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
for i in $lines; do for i in $lines; do
sed "${i}d" "$zshrc" > file.tmp && mv file.tmp "$zshrc" sed "${i}d" $bashrc > file.tmp && mv file.tmp $bashrc
done done
echo 'zsh ~/.welcome/welcome.sh' >> "$zshrc" echo 'bash ~/.welcome/welcome.sh' >> $bashrc
lines=$(grep -sn 'zsh ~/.welcome/welcome.sh' $zshrc | sed -e 's/:.*//g' && grep -sn 'zsh /home/$USER/.welcome/welcome.sh' $zshrc | sed -e 's/:.*//g')
lines=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /g')
for i in $lines; do
sed "${i}d" $zshrc > file.tmp && mv file.tmp $zshrc
done
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
tput rc el ed tput rc el ed
echo -e "\e[32mUpdated to v$version! \e[0m" echo -e "\e[32mUpdated to v$version! \e[0m"
@ -128,12 +131,12 @@ this script!\e[0m Please use \e[3mBash \e[0mor \e[3mZsh.\e[0m\n" "${environment}
fi fi
# Check if already installed # Check if already installed
if ! grep -qs 'bash ~/.welcome/welcome.sh' $bashrc && 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
! 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
#==== Execute if first time installing...====# #==== Execute if first time installing...====#
# To monitor number of downloads/updates
curl https://g2games.dev/Assets/counter/counter.php
tput rc tput rc
echo "Welcome! Installing v$version in $environment..." echo "Welcome! Installing v$version in $environment..."
tput sc tput sc