100 lines
2.6 KiB
Bash
Executable file
100 lines
2.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# shellcheck disable=all
|
|
# This is a handlerbars template, so ignore issues
|
|
|
|
set -xeuo pipefail
|
|
|
|
checksum_file=".dotter/cache/pre_deploy.checksum"
|
|
|
|
if [[ -e "$checksum_file" ]] && sha256sum --check "$checksum_file" >/dev/null 2>&1; then
|
|
echo "Pre deploy script has not changed, skiping script execution"
|
|
echo "To override this, remove the checksum file: $checksum_file"
|
|
exit 0
|
|
fi
|
|
|
|
{{!~ Detect the distribution ~}}
|
|
{{~ assign "distro" (trim (command_output "awk -F= '/^ID=/ {print $2}' /etc/os-release | tr -d '\"'")) ~}}
|
|
|
|
{{ header "Running pre deploy script for distro" (to_title_case distro) }}
|
|
|
|
{{ #if (is_executable "sudo") }}
|
|
{{ header "Configuring sudo" }}
|
|
|
|
SUDOERS_FILE="/etc/sudoers.d/01-user"
|
|
|
|
if [[ -e "${SUDOERS_FILE}" ]]; then
|
|
echo "Sudo configuration already exists, to override it remove the file: ${SUDOERS_FILE}"
|
|
exit 0
|
|
else
|
|
sudo -B tee "${SUDOERS_FILE}" <<EOF
|
|
Defaults pwfeedback
|
|
Defaults timestamp_timeout=10
|
|
Defaults timestamp_type=global
|
|
EOF
|
|
|
|
sudo chmod 0440 "${SUDOERS_FILE}"
|
|
fi
|
|
|
|
{{ /if }}
|
|
|
|
{{#if (eq distro "fedora") ~}}
|
|
|
|
{{! extract the copr repositories variable }}
|
|
{{~ assign "copr" (flatten_table copr) ~}}
|
|
|
|
{{#if (ne (len copr) 0) ~}}
|
|
{{ header "Enabling copr repositories" }}
|
|
|
|
{{# each copr }}
|
|
sudo -B dnf copr enable -y '{{ this }}'
|
|
{{ /each }}
|
|
|
|
{{~ /if }}
|
|
|
|
{{ header "Installing dnf packages" }}
|
|
sudo -B dnf install -y {{~# each (flatten_table packages) }} '{{ this }}' {{~ /each }}
|
|
|
|
{{~ /if }}
|
|
|
|
{{ #if dotter.packages.zsh }}
|
|
|
|
[ "$SHELL" != "$(which zsh)" ] && chsh -s "$(which zsh)"
|
|
|
|
{{ /if }}
|
|
|
|
{{#if (and dotter.packages.rust (not (is_executable "cargo"))) }}
|
|
|
|
{{ header "Installing rust" }}
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable
|
|
|
|
{{ /if }}
|
|
|
|
{{#if (and dotter.packages.rust (ne (len cargo.packages) 0)) }}
|
|
|
|
{{ header "Installing crates" }}
|
|
cargo install --locked {{# each (flatten_table cargo.packages) }} "{{ this }}" {{ /each }}
|
|
|
|
{{ /if }}
|
|
|
|
{{ #if dotter.packages.cli }}
|
|
|
|
{{ header "Configuring Nerd Fonts" }}
|
|
|
|
FONT_DIR="$HOME/.local/share/fonts"
|
|
mkdir -p "$FONT_DIR"
|
|
tmp_dir=$(mktemp -d)
|
|
|
|
curl -L https://github.com/ryanoasis/nerd-fonts/releases/latest/download/{{ nerd_font }}.zip -o "$tmp_dir/{{ nerd_font}}.zip"
|
|
unzip -o "$tmp_dir/{{nerd_font}}.zip" -d ${FONT_DIR}/{{ nerd_font }}
|
|
|
|
curl -L https://github.com/joshmedeski/sesh/releases/latest/download/sesh_Linux_x86_64.tar.gz -o "$tmp_dir/sesh.tar.gz"
|
|
|
|
mkdir -p "$HOME/.local/bin"
|
|
|
|
tar xvf "$tmp_dir/sesh.tar.gz" --directory="$HOME/.local/bin" sesh
|
|
|
|
rm -rf "$tmp_dir"
|
|
|
|
{{ /if }}
|
|
|
|
{{ header "Done :3" }}
|