mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-05-09 22:32:54 -05:00
Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
4912cfa2c8 | |||
9cee7f2904 | |||
b958afb09b | |||
965477d62b | |||
e82a0cf000 | |||
|
f78aed8316 | ||
979978a7f8 |
4 changed files with 51 additions and 17 deletions
|
@ -22,7 +22,7 @@ My goal with this script is to keep it simple, just a single line that gives use
|
|||
<hr>
|
||||
|
||||
### Installing:
|
||||
#### Via Curl
|
||||
#### Automatic Installation via Curl
|
||||
<sub>Bash:</sub>
|
||||
```
|
||||
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`
|
||||
|
||||
#### 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:
|
||||
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
25
cleanup.sh
Normal 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
|
25
install.sh
25
install.sh
|
@ -62,8 +62,8 @@ update () {
|
|||
echo "Updating..."
|
||||
tput sc
|
||||
mkdir -p ~/.welcome
|
||||
rm ~/.welcome/welcome.sh
|
||||
rm ~/.welcome/install.sh
|
||||
rm ~/.welcome/welcome.sh 2> /dev/null
|
||||
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://raw.githubusercontent.com/G2-Games/welcome.sh/main/install.sh --output ~/.welcome/install.sh
|
||||
|
@ -74,19 +74,19 @@ update () {
|
|||
fi
|
||||
|
||||
# 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=$(printf '%s\n' "$lines" | sed '1!G;h;$!d' | sed ':a;N;$!ba;s/\n/ /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') # 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
|
||||
sed "${i}d" "$bashrc" > file.tmp && mv file.tmp "$bashrc"
|
||||
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')
|
||||
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
|
||||
echo 'zsh ~/.welcome/welcome.sh' >> $zshrc
|
||||
echo 'zsh ~/.welcome/welcome.sh' >> "$zshrc"
|
||||
|
||||
tput rc el ed
|
||||
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
|
||||
|
||||
# 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...====#
|
||||
|
||||
tput rc
|
||||
echo "Welcome! Installing v$version in $environment..."
|
||||
tput sc
|
||||
|
|
12
welcome.sh
12
welcome.sh
|
@ -119,12 +119,12 @@ updates () {
|
|||
|
||||
# Check for updates from different places... wonder if there's a better way
|
||||
updchk () {
|
||||
# Check for APT
|
||||
# Check for APT (Debian based)
|
||||
if command -v apt-get &> /dev/null; then
|
||||
debian=$(apt-get -s dist-upgrade -V | grep -c '=>')
|
||||
fi
|
||||
|
||||
# Check for different Arch things
|
||||
# Check for Arch things
|
||||
if command -v checkupdates &> /dev/null; then
|
||||
arch=$(checkupdates 2> /dev/null | wc -l)
|
||||
elif command -v yay &> /dev/null; then
|
||||
|
@ -144,6 +144,12 @@ updates () {
|
|||
fedora=$((fedora-1))
|
||||
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
|
||||
if command -v brew &> /dev/null; then
|
||||
brew=$(brew outdated 2> /dev/null | wc -l)
|
||||
|
@ -155,7 +161,7 @@ updates () {
|
|||
fi
|
||||
|
||||
# Add all update counts together
|
||||
updates=$((debian + arch + fedora + flatpak + brew))
|
||||
updates=$((debian + arch + fedora + suse + flatpak + brew))
|
||||
echo $updates >| ~/.welcome/updates
|
||||
pkill -P "${pid}" sleep # When update checking is finished, kill the sleep function running under this bash process
|
||||
sleep 5
|
||||
|
|
Loading…
Reference in a new issue