mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
feat(bootstrap): Bootstrap script for GNU/Linux without admin
This commit is contained in:
parent
cb81dc8d53
commit
8aa9daf582
12 changed files with 340 additions and 80 deletions
7
bootstrap/linux/appman.bash
Normal file
7
bootstrap/linux/appman.bash
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
echo "[INFO] Installing AppMan"
|
||||
echo "[ACTION] Type [2] to install AppMan"
|
||||
wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/AM-INSTALLER && chmod a+x ./AM-INSTALLER && ./AM-INSTALLER
|
||||
if [ command -v appman ]; then
|
||||
appman install wezterm
|
||||
appman install nvim
|
||||
fi
|
||||
46
bootstrap/linux/chromium-flags.bash
Executable file
46
bootstrap/linux/chromium-flags.bash
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
# chromium-flags.sh
|
||||
# Set Chromium & Electron Flags
|
||||
|
||||
echo "[INFO] Set Chromium & Electron Flags"
|
||||
|
||||
DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
|
||||
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
BROWSER_FLAG=$DOTFILES/platforms/linux/chromium-flags.conf
|
||||
ELECTRON_FLAG=$DOTFILES/platforms/linux/electron-flags.conf
|
||||
|
||||
# Browser Flags
|
||||
|
||||
browser_flags_path=(
|
||||
"$XDG_CONFIG_HOME/chromium-flags.conf" # Chromium
|
||||
"$XDG_CONFIG_HOME/chrome-flags.conf" # Google Chrome
|
||||
"$XDG_CONFIG_HOME/thorium-flags.conf" # Thorium
|
||||
"$XDG_CONFIG_HOME/vivaldi-flags.conf" # Vivaldi
|
||||
"$XDG_CONFIG_HOME/vivaldi-stable.conf" # Vivaldi
|
||||
|
||||
)
|
||||
|
||||
electron_flags_path=(
|
||||
"$XDG_CONFIG_HOME/electron-flags.conf" # General
|
||||
"$XDG_CONFIG_HOME/code-flags.conf" # VSCode
|
||||
"$XDG_CONFIG_HOME/qq-electron-flags.conf" # Slack
|
||||
)
|
||||
|
||||
for path in "${browser_flags_path[@]}"; do
|
||||
if [ -f "$path" ]; then
|
||||
echo "[INFO] Found Browser Flags: $path"
|
||||
else
|
||||
echo "[INFO] Creating Browser Flags: $path"
|
||||
ln -s $BROWSER_FLAG $path
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
for path in "${electron_flags_path[@]}"; do
|
||||
if [ -f "$path" ]; then
|
||||
echo "[INFO] Found Electron Flags: $path"
|
||||
else
|
||||
echo "[INFO] Creating Electron Flags: $path"
|
||||
ln -s $ELECTRON_FLAG $path
|
||||
fi
|
||||
done
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env false
|
||||
# TODO: This script is not ready for use yet
|
||||
# -*- coding: utf-8 -*-
|
||||
# Append Electron argument (for wayland) to *.desktop files
|
||||
|
||||
|
|
|
|||
146
bootstrap/linux/main.bash
Normal file
146
bootstrap/linux/main.bash
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
#!/bin/bash
|
||||
# vim:ft=bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "Running the setup script"
|
||||
|
||||
# Variables
|
||||
|
||||
export DOTFILES="${DOTFILES:-$HOME/.dotfiles}"
|
||||
|
||||
# If is in the sudo or wheel group, set the WHEEL variable to 1
|
||||
WHEEL=0
|
||||
groups "$(whoami)" | grep -E -q '\b(sudo|wheel)\b' && WHEEL=1
|
||||
|
||||
if [ "$WHEEL" -eq 1 ]; then
|
||||
echo "[INFO] Running as sudo or wheel group"
|
||||
else
|
||||
echo "[INFO] Not running as sudo or wheel group"
|
||||
fi
|
||||
|
||||
export WHEEL
|
||||
|
||||
|
||||
GUI_SETUP=0
|
||||
|
||||
if [ "$(uname -r)" = *Microsoft* ]; then
|
||||
echo "[INFO] Running on WSL1 Skipping GUI setup"
|
||||
else
|
||||
read -p "[ACTION] Do you want to setup Linux GUI? (y/N) " choice
|
||||
case "$choice" in
|
||||
y|Y)
|
||||
GUI_SETUP=1
|
||||
;;
|
||||
*)
|
||||
echo "[INFO] Skipping GUI setup"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
export GUI_SETUP
|
||||
|
||||
# base-devel
|
||||
|
||||
if [ "$WHEEL" -eq 1 ]; then
|
||||
echo "[INFO] Installing basic build tools"
|
||||
if [ command -v apt ]; then
|
||||
sudo apt update
|
||||
sudo apt install -y build-essential
|
||||
elif [ command -v pacman ]; then
|
||||
sudo pacman -Syu --noconfirm
|
||||
sudo pacman -S --noconfirm base-devel
|
||||
else
|
||||
echo "[ERROR] Unsupported package manager"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "[INFO] Cloning Dotfiles"
|
||||
|
||||
if [ -d "$DOTFILES" ]; then
|
||||
echo "[INFO] Dotfiles already cloned"
|
||||
elif [ command -v git ]; then
|
||||
git clone https://github.com/js0ny/dotfiles.git "$DOTFILES" --depth 1
|
||||
else
|
||||
echo "[ERROR] Git is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$WHEEL" -eq 0 ]; then
|
||||
read -p "[ACTION] Do you want to install some AppImages (by AppMan)? (y/N) " choice
|
||||
case "$choice" in
|
||||
y|Y)
|
||||
source "$DOTFILES/bootstrap/linux/appman.bash"
|
||||
;;
|
||||
*)
|
||||
echo "[INFO] Skipping AppMan installation"
|
||||
:
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "[INFO] Setting up symbolic links"
|
||||
|
||||
source $DOTFILES/bootstrap/linux/symlinks.bash
|
||||
|
||||
if [ "$WHEEL" -eq 1 ]; then
|
||||
source $DOTFILES/tools/bash/xdg-compact.sh
|
||||
source $DOTFILES/tools/bash/global.bashrc
|
||||
fi
|
||||
source $DOTFILES/tools/bash/profile
|
||||
source $DOTFILES/tools/bash/bashrc
|
||||
source $DOTFILES/tools/bash/bash_aliases
|
||||
|
||||
if [ command -v zsh ]; then
|
||||
read -p "[ACTION] Do you want to setup zsh? (Y/n) " choice
|
||||
case "$choice" in
|
||||
n|N)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
source $DOTFILES/bootstrap/components/zsh.sh
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
if [ "$WHEEL" -eq 0 ]; then
|
||||
echo "Done!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -p "[ACTION] Do you want to use other package managers? (y/N) " choice
|
||||
case "$choice" in
|
||||
y|Y)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
:
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "[INFO] Installing Doom Emacs"
|
||||
|
||||
source $DOTFILES/bootstrap/components/emacs.sh
|
||||
|
||||
if [ "$GUI_SETUP" -eq 0 ]; then
|
||||
echo "Done!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Wayland
|
||||
|
||||
source $DOTFILES/bootstrap/linux/chromium-flags.sh
|
||||
|
||||
# Rime
|
||||
|
||||
source $DOTFILES/bootstrap/components/rime.sh
|
||||
|
||||
# TODO: Rewrite the script(mocha_port.fish) in bash/zsh or POSIX-compliant shell
|
||||
echo "[INFO] Installing Color Scheme (Catppuccin Mocha)"
|
||||
|
||||
fish $DOTFILES/bootstrap/temp/mocha_port.fish
|
||||
|
||||
|
||||
echo "Done!"
|
||||
28
bootstrap/linux/symlinks.bash
Normal file
28
bootstrap/linux/symlinks.bash
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
set -e # Exit immediately if a command exits with a non-zero status
|
||||
|
||||
declare -A linkDots
|
||||
|
||||
|
||||
source "$DOTFILES/bootstrap/components/symlinks.sh"
|
||||
|
||||
echo "[INFO] DOTFILES = $DOTFILES"
|
||||
|
||||
echo "[ACTION] Press any key to proceed"
|
||||
read -n 1
|
||||
|
||||
echo "[INFO] Setting up symbolic links"
|
||||
|
||||
for src in "${!linkDots[@]}"; do
|
||||
dest="${linkDots[$src]}"
|
||||
echo "Linking $src to $dest"
|
||||
if [ -d "$src" ]; then
|
||||
test -d "$dest" && mv "$dest" "$dest.bak"
|
||||
ln -sf "$src" "$dest"
|
||||
elif [ -f "$src" ]; then
|
||||
dest_parent=$(dirname "$dest")
|
||||
test -d "$dest_parent" || mkdir -p "$dest_parent"
|
||||
ln -sf "$src" "$dest"
|
||||
else
|
||||
echo "[ERROR] $src does not exist"
|
||||
fi
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue