Modernize management scripts
This commit is contained in:
parent
6e241e146a
commit
45f0160043
3 changed files with 179 additions and 69 deletions
|
@ -1,48 +1,128 @@
|
|||
#!/bin/bash
|
||||
# Check for sudo
|
||||
if [ ! -f "/sbin/sudo" ]; then
|
||||
echo ":: Error: \"/sbin/sudo\" not found, please install sudo."
|
||||
echo ":: Error: \"/sbin/sudo\" not found, please install sudo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clear variables
|
||||
#PACMAN_FLAGS=
|
||||
INSTALL_GUI_PACKAGES=false
|
||||
|
||||
# Parse arguments
|
||||
for arg in "${@}"; do
|
||||
if [ "${arg}" == "--noconfirm" ]; then
|
||||
# I don't know what shellcheck is seeing here...
|
||||
# shellcheck disable=SC2037
|
||||
PACMAN_FLAGS=${PACMAN_FLAGS} --noconfirm
|
||||
elif [ "${arg}" == "--gui" ]; then
|
||||
INSTALL_GUI_PACKAGES=true
|
||||
else
|
||||
echo ":: Warning: Unknown argument \"${arg}\""
|
||||
fi
|
||||
done
|
||||
|
||||
# Source /etc/os-release
|
||||
echo ":: Detecting distribution"
|
||||
if [ -f "/etc/os-release" ]; then
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/os-release
|
||||
fi
|
||||
|
||||
# Perform actions based on distro
|
||||
case "$ID" in
|
||||
"arch")
|
||||
echo ":: Detected ${PRETTY_NAME}, installing packages automatically"
|
||||
echo ":: Detected Arch Linux, installing packages automatically"
|
||||
|
||||
# Check for paru
|
||||
if [ ! -f "/sbin/paru" ]; then
|
||||
echo ":: Error: \"/sbin/paru\" not found, please install paru."
|
||||
echo ":: Error: \"/sbin/paru\" not found, please install paru"
|
||||
exit 1
|
||||
fi
|
||||
if [ "${1}" == "--noconfirm" ]; then
|
||||
export "PARU_FLAGS=--noconfirm"
|
||||
else
|
||||
export "PARU_FLAGS="
|
||||
fi
|
||||
paru --removemake --batchinstall --sudoloop --mflags "--ignorearch" -Syu --needed bash ncurses nano rustup bat moar fireplace fortune-mod cowsay ytfzf yt-dlp-git tar zstd bzip zip unrar unzip 7-zip binutils ${PARU_FLAGS}
|
||||
rustup default nightly
|
||||
rustup update
|
||||
cargo install eza
|
||||
curl -s "https://get.sdkman.io" | bash
|
||||
export SDKMAN_DIR="$HOME/.sdkman"
|
||||
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
sdk selfupdate
|
||||
sdk update
|
||||
java_versions=( '22.0.1' '21.0.3' '17.0.11' '8.0.412' )
|
||||
for version in "${java_versions[@]}"; do
|
||||
sdk install java "${version}-tem"
|
||||
done
|
||||
sdk default java 21.0.3-tem
|
||||
|
||||
# Install required packages (command line)
|
||||
# shellcheck disable=SC2086
|
||||
paru --removemake --batchinstall --sudoloop --mflags "--ignorearch" -Syu --needed ${PACMAN_FLAGS} \
|
||||
nano ncurses moar fireplace sl fortune-mod cowsay lolcat \
|
||||
moar yt-dlp-git tar zstd bzip zip unrar unzip 7-zip \
|
||||
rustup binutils base-devel
|
||||
|
||||
# Install required packages packages (graphical)
|
||||
# shellcheck disable=SC2086
|
||||
[[ -n "${INSTALL_GUI_PACKAGES}" ]] && \
|
||||
paru --removemake --batchinstall --sudoloop --mflags "--ignorearch" -Syu --needed ${PACMAN_FLAGS} \
|
||||
hyprland-git hyprpaper-git waybar fnott qt6ct bemenu \
|
||||
cliphist j4-dmenu-desktop polkit-kde-agent polkit-qt6 \
|
||||
xdg-desktop-portal-hyprland xdg-desktop-portal-kde \
|
||||
qt6-wayland qt5-wayland xwaylandvideobridge pipewire \
|
||||
wireplumber
|
||||
|
||||
# Install/update Rust toolchains and Rust-based software
|
||||
(
|
||||
# Update installed toolchains
|
||||
rustup update
|
||||
|
||||
# Install nightly and stable toolchains
|
||||
rustup install stable
|
||||
rustup install nightly
|
||||
|
||||
# Switch to stable toolchain
|
||||
rustup default stable
|
||||
|
||||
# Install software
|
||||
cargo install eza cargo-audit
|
||||
)
|
||||
|
||||
# Install SDKMAN! and Java
|
||||
(
|
||||
# Download & install SDKMAN!
|
||||
curl -s "https://get.sdkman.io" | bash
|
||||
|
||||
# Initialize SDKMAN! for subshell
|
||||
export SDKMAN_DIR="$HOME/.sdkman"
|
||||
# shellcheck disable=SC1091
|
||||
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||
|
||||
# Update SDKMAN! and installed candidates
|
||||
sdk selfupdate
|
||||
sdk update
|
||||
|
||||
# Install Java versions specified in array
|
||||
# We use the Temurin distribution of Java.
|
||||
|
||||
java_versions=( '22.0.1' '21.0.3' '17.0.11' '8.0.412' )
|
||||
for version in "${java_versions[@]}"; do
|
||||
sdk install java "${version}-tem"
|
||||
done
|
||||
|
||||
# Default to Java 21
|
||||
sdk default java 21.0.3-tem
|
||||
)
|
||||
|
||||
# Install Hyprland plugins
|
||||
(
|
||||
# Install Hyprland headers & update existing plugins
|
||||
hyprpm update
|
||||
|
||||
# Add hyprland-plugins repository
|
||||
yes | hyprpm add https://github.com/hyprwm/hyprland-plugins
|
||||
|
||||
# Enable plugins
|
||||
hyprpm enable csgo-vulkan-fix
|
||||
)
|
||||
|
||||
;;
|
||||
"archarm")
|
||||
echo ":: Arch Linux ARM is not yet supported"
|
||||
echo " (but will soon be). Just wait a little!"
|
||||
|
||||
;;
|
||||
*)
|
||||
echo ":: No supported distribution found."
|
||||
echo " Please create an issue and (if you want)"
|
||||
echo " look into the source code and install"
|
||||
echo " the packages and programs yourself."
|
||||
echo ":: Hmm... your distribution isn't supported"
|
||||
echo " You can do the following:"
|
||||
echo " - Create an issue"
|
||||
echo " - Look into the source for this script"
|
||||
echo " and install the required software yourself"
|
||||
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,32 +1,46 @@
|
|||
#!/bin/bash
|
||||
cd "$HOME/.dotfiles"
|
||||
export "COLOR=31"
|
||||
export "COLOR_REGULAR=\e[0;${COLOR}m"
|
||||
export "COLOR_BOLD=\e[1;${COLOR}m"
|
||||
export "COLOR_RESET=\e[0m"
|
||||
export "COMMIT=$(env PAGER= git log -n 1 --pretty=format:\"%H\")"
|
||||
export "LATEST_COMMIT=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.id')"
|
||||
export "LATEST_COMMIT_MESSAGE=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.message'|sed 's/\\n//g')"
|
||||
cd "${HOME}/.dotfiles" || (
|
||||
echo ":: Error: Can't cd into ${HOME}/.dotfiles"
|
||||
exit 1
|
||||
)
|
||||
|
||||
if [ "$COMMIT" == "$LATEST_COMMIT" ] || [ -z "$LATEST_COMMIT" ]; then
|
||||
export "UPDATE=false"
|
||||
# Colors
|
||||
COLOR="31"
|
||||
COLOR_REGULAR="\e[0;${COLOR}m"
|
||||
COLOR_BOLD="\e[1;${COLOR}m"
|
||||
COLOR_RESET="\e[0m"
|
||||
|
||||
# Latest commit
|
||||
if curl -qsI https://git.staropensource.de|head -1|grep " 200" &> /dev/null; then
|
||||
COMMIT=$(env PAGER= git log -n 1 --pretty=format:\"%H\")
|
||||
LATEST_COMMIT=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.id')
|
||||
LATEST_COMMIT_MESSAGE=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.message'|sed 's/\\n//g')
|
||||
else
|
||||
export "UPDATE=true"
|
||||
[[ -z "${SCRIPTED}" ]] && echo -e "${COLOR_BOLD}https://git.staropensource.de is not reachable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! "$SCRIPTED" == "true" ]; then
|
||||
if [ "$UPDATE" == "true" ]; then
|
||||
if [ "$COMMIT" == "$LATEST_COMMIT" ] || [ -z "$LATEST_COMMIT" ]; then
|
||||
UPDATE=false
|
||||
else
|
||||
UPDATE=true
|
||||
fi
|
||||
|
||||
if [ -z "${SCRIPTED}" ]; then
|
||||
if [ -n "${UPDATE}" ]; then
|
||||
echo -e "${COLOR_BOLD}An update for jstm's punktdateien is available."
|
||||
echo -e "${COLOR_REGULAR}Latest commit: ${LATEST_COMMIT}"
|
||||
echo " -> Message: ${LATEST_COMMIT_MESSAGE}"
|
||||
echo ""
|
||||
echo -e "${COLOR_BOLD}Update by executing \"dotfiles-updater\""
|
||||
echo -en "${COLOR_RESET}"
|
||||
elif [ ! "${BASHRC}" == "true" ]; then
|
||||
exit 0
|
||||
elif [ -z "${BASHRC}" ]; then
|
||||
echo -e "${COLOR_BOLD}No update available"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ "$UPDATE" == "true" ]; then
|
||||
if [ -n "${UPDATE}" ]; then
|
||||
echo "$LATEST_COMMIT_MESSAGE"
|
||||
fi
|
||||
fi
|
||||
|
|
70
bin/updater
70
bin/updater
|
@ -1,28 +1,44 @@
|
|||
#!/bin/bash
|
||||
export "UPDATER_VERSION=1"
|
||||
if [ "$STAGE" == "1" ]; then
|
||||
echo ":: Removing files (again)"
|
||||
./uninstall.sh
|
||||
echo ":: Installing files"
|
||||
./install.sh
|
||||
rm -rf "$HOME/.config/.jstm_dotfiles_updater"
|
||||
echo ":: Update complete."
|
||||
echo " Please execute \"dotfiles-install-software\" to"
|
||||
echo " install and update required software."
|
||||
else
|
||||
echo ":: Checking for updates"
|
||||
if [ ! "$1" == "--force" ] && [ "$(env SCRIPTED=true dotfiles-updatechecker)" == "" ]; then
|
||||
echo ":: No update is available. Use \"--force\" to update anyway."
|
||||
exit 1
|
||||
fi
|
||||
# Unused as of now, may be used in a later commit
|
||||
echo ":: Writing info file"
|
||||
echo "UPDATER_VERSION_OLD=${UPDATER_VERSION}" > "$HOME/.config/.jstm_dotfiles_updater"
|
||||
echo ":: Removing files"
|
||||
cd "$HOME/.dotfiles"
|
||||
./uninstall.sh
|
||||
echo ":: Pulling updates"
|
||||
git pull
|
||||
echo ":: Running updater (stage 2)"
|
||||
exec env STAGE=1 "$HOME/.dotfiles/bin/updater"
|
||||
fi
|
||||
cd "${HOME}/.dotfiles" || (
|
||||
echo ":: Error: Can't cd into ${HOME}/.dotfiles"
|
||||
exit 1
|
||||
)
|
||||
|
||||
# Define updater version
|
||||
UPDATER_VERSION=2
|
||||
|
||||
case "${STAGE}" in
|
||||
1)
|
||||
echo ":: 1 | Unlinking files"
|
||||
./uninstall.sh
|
||||
|
||||
echo ":: 1 | Linking files"
|
||||
./install.sh
|
||||
|
||||
# Remove legacy updater version file
|
||||
rm -rf "$HOME/.config/.jstm_dotfiles_updater"
|
||||
|
||||
echo ":: 1 | Update complete."
|
||||
echo " Make sure to execute \"dotfiles-install-software\""
|
||||
echo " to install/update required software."
|
||||
echo " Append \"--gui\" to install required GUI stuff."
|
||||
|
||||
;;
|
||||
*)
|
||||
echo ":: Checking for updates"
|
||||
|
||||
if [ ! "${1}" == "--force" ] && [ "$(env SCRIPTED=true dotfiles-updatechecker)" == "" ]; then
|
||||
echo ":: No update is available. Use \"--force\" to update anyway."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ":: S0 | Unlinking files"
|
||||
./uninstall.sh
|
||||
|
||||
echo ":: S0 | Pulling updates"
|
||||
git pull
|
||||
|
||||
exec env STAGE=1 UPDATER_VERSION=${UPDATER_VERSION} "$HOME/.dotfiles/bin/updater"
|
||||
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue