lots of shit
This commit is contained in:
@ -1,25 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/lists/apt.sh
|
||||
|
||||
add_wezterm_repo() {
|
||||
# Check if we have a wezterm.list file already, if not then create one
|
||||
if [ ! -f /etc/apt/sources.list.d/wezterm.list ]; then
|
||||
curl -fsSL https://apt.fury.io/wez/gpg.key | sudo gpg --yes --dearmor -o /usr/share/keyrings/wezterm-fury.gpg
|
||||
echo 'deb [signed-by=/usr/share/keyrings/wezterm-fury.gpg] https://apt.fury.io/wez/ * *' | sudo tee /etc/apt/sources.list.d/wezterm.list
|
||||
result=$(sudo apt update 2>&1)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
printfe "%s\n" "red" " - Failed to add Wezterm repository"
|
||||
printfe "%s\n" "yellow" "$result"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printfe "%s\n" "yellow" " - Added Wezterm repository"
|
||||
else
|
||||
printfe "%s\n" "green" " - Wezterm repository already added"
|
||||
fi
|
||||
}
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
add_brave_repo() {
|
||||
# Check if we have a brave-browser-release.list file already, if not then create one
|
||||
@ -104,14 +85,38 @@ add_vscode_repo() {
|
||||
}
|
||||
|
||||
ensure_repositories() {
|
||||
add_wezterm_repo
|
||||
add_brave_repo
|
||||
add_1password_repo
|
||||
add_spotify_repo
|
||||
add_vscode_repo
|
||||
}
|
||||
|
||||
repos=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.apt.repos))
|
||||
for repo in $repos; do
|
||||
repo_name=$(echo $repo | cut -d ":" -f 2)
|
||||
|
||||
# Go through sources.list.d and check if there's a file containing part of URIs: https://ppa.launchpad.net/$repo_name
|
||||
# We have to check the files not the file names since the file names are not always the same as the repo_name
|
||||
result=$(grep -r "$repo_name" /etc/apt/sources.list.d/*)
|
||||
if [ -z "$result" ]; then
|
||||
printfe "%s\n" "yellow" " - Adding $repo_name repository..."
|
||||
clear_line
|
||||
|
||||
sudo add-apt-repository -y $repo
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
printfe "%s\n" "red" " - Failed to add $repo_name repository"
|
||||
exit 1
|
||||
else
|
||||
printfe "%s\n" "green" " - $repo_name repository added successfully"
|
||||
fi
|
||||
else
|
||||
printfe "%s\n" "green" " - $repo_name repository already added"
|
||||
fi
|
||||
done
|
||||
}
|
||||
ensure_apt_packages_installed() {
|
||||
apt_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.apt.apps))
|
||||
|
||||
# Check if apt_packages array contains duplicates
|
||||
if [ $(echo $apt_packages | tr ' ' '\n' | sort | uniq -d | wc -l) -ne 0 ]; then
|
||||
printfe "%s\n" "red" "The apt_packages array contains duplicates"
|
||||
@ -149,6 +154,8 @@ print_apt_status() {
|
||||
printfe "%s" "cyan" "Checking APT packages..."
|
||||
clear_line
|
||||
|
||||
apt_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.apt.apps))
|
||||
|
||||
# count entries in packages
|
||||
count=$(echo $apt_packages | wc -w)
|
||||
installed=0
|
||||
|
@ -1,29 +1,38 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source ~/dotfiles/bin/lists/cargo.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_cargo_packages_installed() {
|
||||
# Check if cargo_packages array contains duplicates
|
||||
if [ $(echo $cargo_packages | tr ' ' '\n' | sort | uniq -d | wc -l) -ne 0 ]; then
|
||||
printfe "%s\n" "red" "The cargo_packages array contains duplicates"
|
||||
printfe "%s\n" "yellow" "Duplicates:"
|
||||
printfe "%s\n" "blue" $(echo $cargo_packages | tr ' ' '\n' | sort | uniq -d)
|
||||
exit 1
|
||||
fi
|
||||
cargo_packages=($(cat $DOTFILES_CONFIG | shyaml keys config.packages.cargo))
|
||||
for package in "${cargo_packages[@]}"; do
|
||||
printfe "%s" "cyan" " - Checking $package..."
|
||||
echo -en '\r'
|
||||
|
||||
for package in $cargo_packages; do
|
||||
# Some entries have a git_url and binary, we need to load these in if they exist
|
||||
pkg_status=$(cargo install --list | grep -E "^${package}\sv[0-9.]+:$")
|
||||
package_url=$(cat $DOTFILES_CONFIG | shyaml get-value config.packages.cargo.$package.git_url 2>/dev/null)
|
||||
binary=$(cat $DOTFILES_CONFIG | shyaml get-value config.packages.cargo.$package.binary 2>/dev/null)
|
||||
|
||||
# If pkg_status is `installed` then we don't need to install the package, otherwise if it's empty then the package is not installed
|
||||
if [ -z $pkg_status ]; then
|
||||
ensure_sudo_privileges "In order to install cargo_packages, please provide your password:"
|
||||
printfe "%s" "yellow" " - Installing $package..."
|
||||
ensure_sudo_privileges "In order to install $package, please provide your password:"
|
||||
printfe "%s" "yellow" " - Compiling/Installing $package... (This may take a while)"
|
||||
clear_line
|
||||
result=$(cargo install $package 2>&1)
|
||||
|
||||
# If package_url is defined we should install via git
|
||||
if [ -n "$package_url" ]; then
|
||||
command="cargo install --git $package_url $binary"
|
||||
else
|
||||
command="cargo install $package"
|
||||
fi
|
||||
|
||||
# Execute the command
|
||||
result=$(eval $command 2>&1)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
printfe "%s\n" "red" " - Failed to install $package"
|
||||
printfe "%s\n" "red" " Command: $command"
|
||||
printfe "%s\n" "red" " Output: $result"
|
||||
exit 1
|
||||
fi
|
||||
printfe "%s\n" "green" " - Installed $package"
|
||||
@ -37,6 +46,7 @@ print_cargo_status() {
|
||||
printfe "%s" "cyan" "Checking Cargo packages..."
|
||||
clear_line
|
||||
|
||||
cargo_packages=($(cat $DOTFILES_CONFIG | shyaml keys config.packages.cargo))
|
||||
count=$(echo $cargo_packages | wc -w)
|
||||
installed=0
|
||||
|
||||
|
34
bin/helpers/docker.sh
Executable file
34
bin/helpers/docker.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
ensure_docker_installed() {
|
||||
# if docker is already installed, skip the installation
|
||||
if [ -x "$(command -v docker)" ]; then
|
||||
printfe "%s\n" "green" " - Docker is already installed"
|
||||
return
|
||||
fi
|
||||
|
||||
# Add Docker's official GPG key
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
|
||||
# Add Docker's repository
|
||||
sudo add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) \
|
||||
stable"
|
||||
|
||||
sudo apt update
|
||||
sudo apt install -y docker-ce docker-ce-cli containerd.io
|
||||
|
||||
# Check if it successfully installed
|
||||
if [ -x "$(command -v docker)" ]; then
|
||||
printfe "%s\n" "green" " - Docker is installed"
|
||||
else
|
||||
printfe "%s\n" "red" " - Docker is not installed"
|
||||
printfe "%s\n" "red" " Something went wrong while installing Docker, investigate the issue"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo usermod -aG docker $USER
|
||||
sudo systemctl start docker
|
||||
sudo systemctl enable docker
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source ~/dotfiles/bin/lists/flatpak.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_remotes_added() {
|
||||
flatpak_remotes=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.flatpak.remotes))
|
||||
|
||||
for remote in $flatpak_remotes; do
|
||||
printfe "%s\n" "green" " - Ensuring remote $remote"
|
||||
flatpak remote-add --if-not-exists flathub $remote
|
||||
@ -11,6 +12,7 @@ ensure_remotes_added() {
|
||||
}
|
||||
|
||||
ensure_flatpak_packages_installed() {
|
||||
flatpak_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.flatpak.apps))
|
||||
for package in $flatpak_packages; do
|
||||
if ! flatpak list | grep -q $package; then
|
||||
printfe "%s" "yellow" " - Installing $package"
|
||||
@ -32,6 +34,8 @@ print_flatpak_status() {
|
||||
printfe "%s" "cyan" "Checking Flatpak packages..."
|
||||
clear_line
|
||||
|
||||
flatpak_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.flatpak.apps))
|
||||
|
||||
count=$(echo $flatpak_packages | wc -w)
|
||||
installed=0
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source ~/dotfiles/bin/lists/fonts.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
install_font() {
|
||||
font_url="$1"
|
||||
@ -53,8 +52,13 @@ install_font() {
|
||||
}
|
||||
|
||||
ensure_fonts_installed() {
|
||||
# Load fonts from cat $DOTFILES_CONFIG | shyaml keys config.fonts
|
||||
fonts=($(cat $DOTFILES_CONFIG | shyaml keys config.fonts))
|
||||
|
||||
for font in "${fonts[@]}"; do
|
||||
install_font $(echo $font | awk '{print $1}') $(echo $font | awk '{print $2}')
|
||||
name=$(cat $DOTFILES_CONFIG | shyaml get-value config.fonts.$font.name)
|
||||
url=$(cat $DOTFILES_CONFIG | shyaml get-value config.fonts.$font.url)
|
||||
install_font $url $name
|
||||
done
|
||||
}
|
||||
|
||||
@ -67,6 +71,7 @@ print_fonts_status() {
|
||||
|
||||
mkdir -p $font_dir
|
||||
|
||||
fonts=($(cat $DOTFILES_CONFIG | shyaml keys config.fonts))
|
||||
total_fonts=0
|
||||
installed_fonts=0
|
||||
|
||||
|
@ -8,7 +8,7 @@ println() {
|
||||
|
||||
logo() {
|
||||
tput setaf 2
|
||||
cat ~/dotfiles/bin/resources/logo.txt
|
||||
cat $HOME/dotfiles/bin/resources/logo.txt
|
||||
println " " "cyan"
|
||||
tput sgr0
|
||||
|
||||
|
@ -1,8 +1,13 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_gnome_extensions_installed() {
|
||||
if ! command -v gnome-extensions &> /dev/null; then
|
||||
printfe "%s\n" "red" " - gnome-extensions command not found, likely not running GNOME."
|
||||
return
|
||||
fi
|
||||
|
||||
printfe "%s" "cyan" " - Loading GNOME extension json file..."
|
||||
echo -en '\r'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
# Ensure jq is installed
|
||||
if ! command -v jq &> /dev/null; then
|
||||
@ -17,7 +17,21 @@ fi
|
||||
|
||||
shortcuts=$(jq -r '.shortcuts' "${shortcuts_file}")
|
||||
|
||||
ensure_swhkd() {
|
||||
shortcuts_keys=($(cat "$DOTFILES_CONFIG" | shyaml keys config.keybinds))
|
||||
for key in "${shortcuts_keys[@]}"; do
|
||||
shortcut=$(cat "$DOTFILES_CONFIG" | shyaml get-value config.keybinds.$key.shortcut)
|
||||
command=$(cat "$DOTFILES_CONFIG" | shyaml get-value config.keybinds.$key.command)
|
||||
echo "$shortcut"
|
||||
echo " $command"
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
||||
ensure_keyboard_shortcuts() {
|
||||
printfe "%s\n" "green" " - Setting up swhkd configuration..."
|
||||
ensure_swhkd > $HOME/dotfiles/config/swhkd/swhkdrc
|
||||
|
||||
# Retrieve current custom keybindings
|
||||
existing_bindings=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | tr -d "[]'")
|
||||
new_bindings=()
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_ohmyzsh_installed() {
|
||||
if [ -d ~/.oh-my-zsh ]; then
|
||||
|
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source ~/dotfiles/bin/lists/pipx.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_pipx_packages_installed() {
|
||||
pipx_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.pipx))
|
||||
for i in "${pipx_packages[@]}";
|
||||
do
|
||||
printfe "%s" "cyan" " - Fetching package details for $i"
|
||||
@ -31,6 +31,7 @@ print_pipx_status() {
|
||||
printfe "%s" "cyan" "Checking pipx packages..."
|
||||
clear_line
|
||||
|
||||
pipx_packages=($(cat $DOTFILES_CONFIG | shyaml get-values config.packages.pipx))
|
||||
count=$(echo $pipx_packages | wc -w)
|
||||
installed=0
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_rust_installed() {
|
||||
if [ -x "$(command -v rustc)" ]; then
|
||||
|
33
bin/helpers/tailscale.sh
Executable file
33
bin/helpers/tailscale.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
ensure_tailscale_installed() {
|
||||
# if tailscale is already installed, skip the installation
|
||||
if [ -x "$(command -v tailscale)" ]; then
|
||||
printfe "%s\n" "green" " - Tailscale is already installed"
|
||||
return
|
||||
fi
|
||||
|
||||
result=$(curl -fsSL https://tailscale.com/install.sh | sh)
|
||||
|
||||
# Ensure it ended with something like Installation complete
|
||||
if [[ $result == *"Installation complete"* ]]; then
|
||||
# Check if it successfully installed
|
||||
if [ -x "$(command -v tailscale)" ]; then
|
||||
printfe "%s\n" "green" " - Tailscale is installed"
|
||||
else
|
||||
printfe "%s\n" "red" " - Tailscale is not installed"
|
||||
printfe "%s\n" "red" " Something went wrong while installing Tailscale, investigate the issue"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
printfe "%s\n" "red" " - Tailscale is not installed"
|
||||
printfe "%s\n" "red" " Something went wrong while installing Tailscale, investigate the issue"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Let's set the current user to the operator
|
||||
sudo tailscale set --operator=$USER
|
||||
|
||||
# Start the service
|
||||
tailscale up
|
||||
}
|
42
bin/helpers/user_groups.sh
Executable file
42
bin/helpers/user_groups.sh
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_user_groups() {
|
||||
# Load yaml file
|
||||
users=($(cat $DOTFILES_CONFIG | shyaml keys config.user_groups))
|
||||
|
||||
# For each user, ensure they are in the correct groups
|
||||
for user in $users; do
|
||||
# Ensure this user exists
|
||||
if [[ ! $(id -u $user) ]]; then
|
||||
printfe "%s\n" "red" " - User $user does not exist"
|
||||
continue
|
||||
fi
|
||||
|
||||
ensure_user_in_groups $user
|
||||
done
|
||||
}
|
||||
|
||||
ensure_user_in_groups() {
|
||||
user=$1
|
||||
groups=($(cat $DOTFILES_CONFIG | shyaml get-values config.user_groups.$user))
|
||||
|
||||
printfe "%s\n" "cyan" " - For user $user..."
|
||||
|
||||
# For each group, ensure the user is in it
|
||||
for group in $groups; do
|
||||
# Check if the group exists at all, otherwise skip
|
||||
if [[ ! $(getent group $group) ]]; then
|
||||
printfe "%s\n" "red" " Group $group does not exist"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ! $groups == *$group* ]]; then
|
||||
printfe "%s\n" "green" " Adding $user to group $group"
|
||||
sudo usermod -aG $group $user
|
||||
else
|
||||
printfe "%s\n" "green" " $user is already in group $group"
|
||||
fi
|
||||
done
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
source ~/dotfiles/bin/helpers/functions.sh
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
load_vscode_extensions() {
|
||||
# Clear the array before populating it
|
||||
|
Reference in New Issue
Block a user