Compare commits

...

7 commits
v1.1.2 ... main

4 changed files with 51 additions and 17 deletions

View file

@ -22,7 +22,7 @@ My goal with this script is to keep it simple, just a single line that gives use
<hr> <hr>
### Installing: ### Installing:
#### Via Curl #### Automatic Installation via Curl
<sub>Bash:</sub> <sub>Bash:</sub>
``` ```
bash -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh)" bash -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh)"
@ -35,7 +35,7 @@ zsh -c "$(curl -s https://raw.githubusercontent.com/G2-Games/welcome.sh/main/ins
It installs to `~/.welcome/welcome.sh`, and adds a line to the bottom of `~/.bashrc` or `~/.zshrc` It installs to `~/.welcome/welcome.sh`, and adds a line to the bottom of `~/.bashrc` or `~/.zshrc`
#### Manual Installation #### Manual Installation
To use it, download the latest `welcome.sh` from <a href="https://github.com/G2-Games/welcome.sh/releases/latest">releases</a> and place it in your home directory. Then add `bash ~/welcome.sh` to your `.bashrc`. It works without the config file, but you can also add that to your home directory for easier manual updates. To install it manually, download the latest `welcome.sh` from <a href="https://github.com/G2-Games/welcome.sh/releases/latest">releases</a> and place it in your home directory. Then add `bash ~/welcome.sh` to your `.bashrc`. It works without the config file, but you can also add that to your home directory for easier manual updates.
### Updating: ### Updating:
Run the script again to check for an update. If you have an older version it will prompt you. You can update **from** any version **to** any newer version. The proper files will be downloaded as necessary. Run the script again to check for an update. If you have an older version it will prompt you. You can update **from** any version **to** any newer version. The proper files will be downloaded as necessary.

25
cleanup.sh Normal file
View file

@ -0,0 +1,25 @@
#!/bin/bash
version=1
echo "Ensuring welcome.sh is installed in the new location..."
# Check if welcome.sh is installed in the old location
if [[ -f ~/.welcome ]]\
|| [[ -f ~/.welcome/welcome.sh ]]\
|| [[ -f ~/.welcome/config.cfg ]];
then
# Modify the files with proper paths
sed "${i}d" "$zshrc" > file.tmp && mv file.tmp "$zshrc"
# Create the directories in the proper spots
mkdir -p ~/.config/welcome.sh/
mkdir -p ~/.local/bin/
# Move the welcome files to the proper folders
mv ~/.welcome/config.cfg ~/.config/welcome.sh/config.cfg
mv ~/.welcome/welcome.sh ~/.local/bin/welcome.sh
echo "welcome.sh is now installed in the new location!"
else
echo "welcome.sh is already installed properly!"
fi

View file

@ -62,8 +62,8 @@ update () {
echo "Updating..." echo "Updating..."
tput sc tput sc
mkdir -p ~/.welcome mkdir -p ~/.welcome
rm ~/.welcome/welcome.sh rm ~/.welcome/welcome.sh 2> /dev/null
rm ~/.welcome/install.sh rm ~/.welcome/install.sh 2> /dev/null
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 +74,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') 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=$(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') # Format the line number properly (macos doesn't have Cut)
for i in $lines; do for i in $lines; do
sed "${i}d" $bashrc > file.tmp && mv file.tmp $bashrc sed "${i}d" "$bashrc" > file.tmp && mv file.tmp "$bashrc"
done done
echo 'bash ~/.welcome/welcome.sh' >> $bashrc 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=$(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" "$zshrc" > file.tmp && mv file.tmp "$zshrc"
done done
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc 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,9 +128,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 && ! 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 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
#==== Execute if first time installing...====# #==== Execute if first time installing...====#
tput rc tput rc
echo "Welcome! Installing v$version in $environment..." echo "Welcome! Installing v$version in $environment..."
tput sc tput sc

View file

@ -119,12 +119,12 @@ updates () {
# Check for updates from different places... wonder if there's a better way # Check for updates from different places... wonder if there's a better way
updchk () { updchk () {
# Check for APT # Check for APT (Debian based)
if command -v apt-get &> /dev/null; then if command -v apt-get &> /dev/null; then
debian=$(apt-get -s dist-upgrade -V | grep -c '=>') debian=$(apt-get -s dist-upgrade -V | grep -c '=>')
fi fi
# Check for different Arch things # Check for Arch things
if command -v checkupdates &> /dev/null; then if command -v checkupdates &> /dev/null; then
arch=$(checkupdates 2> /dev/null | wc -l) arch=$(checkupdates 2> /dev/null | wc -l)
elif command -v yay &> /dev/null; then elif command -v yay &> /dev/null; then
@ -144,6 +144,12 @@ updates () {
fedora=$((fedora-1)) fedora=$((fedora-1))
fi fi
# Check for OpenSUSE things
if command -v zypper &> /dev/null; then
suse=$(zypper list-updates 2> /dev/null | wc -l)
suse=$((suse-4))
fi
# Check for Brew updates # Check for Brew updates
if command -v brew &> /dev/null; then if command -v brew &> /dev/null; then
brew=$(brew outdated 2> /dev/null | wc -l) brew=$(brew outdated 2> /dev/null | wc -l)
@ -155,7 +161,7 @@ updates () {
fi fi
# Add all update counts together # Add all update counts together
updates=$((debian + arch + fedora + flatpak + brew)) updates=$((debian + arch + fedora + suse + flatpak + brew))
echo $updates >| ~/.welcome/updates echo $updates >| ~/.welcome/updates
pkill -P "${pid}" sleep # When update checking is finished, kill the sleep function running under this bash process pkill -P "${pid}" sleep # When update checking is finished, kill the sleep function running under this bash process
sleep 5 sleep 5