rmm-scripts/izebra-linux-oneshot.sh

65 lines
2.3 KiB
Bash
Raw Normal View History

2024-07-24 19:09:09 +00:00
#!/bin/bash
#Linux Onboarding Oneshot script for izebra networks.
#Installs fish, starship, and sets up some shell tweaks that are nice to have.
#Check script is running as root
2024-07-24 19:13:47 +00:00
if [ "$EUID" -ne 0 ]
2024-07-24 19:09:09 +00:00
then echo "Please run as Root"
exit 1
fi
#define variables
2024-07-24 19:15:44 +00:00
fishconfig="https://git.izebra.net/izebra_projects/rmm-scripts/raw/branch/main/config-files/config.fish"
starshipconfig="https://git.izebra.net/izebra_projects/rmm-scripts/raw/branch/main/config-files/starship.toml"
2024-07-24 19:09:09 +00:00
#Check for updates
sudo apt update
#install fish and copy config file to root and all users under /home/
sudo apt install fish -y
2024-07-24 19:41:29 +00:00
wget -O "$HOME/.config/fish/config.fish" $fishconfig
# Iterate over each user's home directory, including /root
2024-07-24 20:34:47 +00:00
for homedir in /root /home/*; do
2024-07-24 19:41:29 +00:00
if [ -d "$homedir" ]; then
# Ensure .config directory exists
mkdir -p "$homedir/.config"
mkdir -p "$homedir/.config/fish"
# Copy starship.toml to the user's .config directory
cp "$HOME/.config/fish/config.fish" "$homedir/.config/fish/config.fish"
# Set ownership to the user of the home directory
chown $(basename "$homedir"):"$(id -gn $(basename "$homedir"))" "$homedir/.config/fish/config.fish"
# Optional: Set permissions to 0644 (readable by owner and group, readable by others)
chmod 0644 "$homedir/.config/fish/config.fish"
fi
2024-07-24 19:09:09 +00:00
done
#install pyenv
curl https://pyenv.run | bash
#Download starship and copy config file to root and all users under /home/
2024-07-24 20:34:47 +00:00
curl -sS https://starship.rs/install.sh | yes | sh
2024-07-24 19:41:29 +00:00
wget -O "$HOME/.config/starship.toml" $starshipconfig
# Iterate over each user's home directory, including /root
2024-07-24 20:34:47 +00:00
for homedir in /root /home/*; do
2024-07-24 19:41:29 +00:00
if [ -d "$homedir" ]; then
# Ensure .config directory exists
mkdir -p "$homedir/.config"
2024-07-24 19:20:50 +00:00
2024-07-24 19:41:29 +00:00
# Copy starship.toml to the user's .config directory
cp "$HOME/.config/starship.toml" "$homedir/.config/starship.toml"
# Set ownership to the user of the home directory
chown $(basename "$homedir"):"$(id -gn $(basename "$homedir"))" "$homedir/.config/starship.toml"
# Optional: Set permissions to 0644 (readable by owner and group, readable by others)
chmod 0644 "$homedir/.config/starship.toml"
fi
2024-07-24 19:09:09 +00:00
done
#Change default shell to fish
chsh -s /usr/bin/fish