rm: archive (that's what git is for)
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ---
|
||||
# @file_name: mullvad_tailscale.sh
|
||||
# @version: 1.0.0
|
||||
# @description: Installs mullvad nft rules
|
||||
# @author: Jamie Albert (empty_produce)
|
||||
# @author_contact: <mailto:empty.produce@flatmail.me>
|
||||
# @license: GNU Affero General Public License v3.0 (Included in LICENSE)
|
||||
# Copyright (C) 2025, Jamie Albert
|
||||
# ---
|
||||
|
||||
# ---
|
||||
# shellcheck disable=1091
|
||||
# --
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
setup() {
|
||||
. /usr/local/share/dao/config/dao.conf
|
||||
}
|
||||
|
||||
wait_for_network() {
|
||||
echo "[i] Waiting for network connectivity..."
|
||||
local max_attempts=30
|
||||
local attempt=1
|
||||
|
||||
while ! ping -c1 -W1 nasa.gov >/dev/null 2>&1; do
|
||||
if [ $attempt -ge $max_attempts ]; then
|
||||
echo "[e] Network not available after ${max_attempts} attempts"
|
||||
exit 1
|
||||
fi
|
||||
echo "[i] Attempt $attempt/${max_attempts}: Network not ready, waiting 2 seconds..."
|
||||
sleep 2
|
||||
((attempt++))
|
||||
done
|
||||
echo "[i] Network connectivity confirmed"
|
||||
}
|
||||
|
||||
nft_mullvad() {
|
||||
echo "[i] Applying firewall rules..."
|
||||
if sudo nft -f "$DAO_USER_HOME/.config/dao/firewall/mullvad_tailscale.conf"; then
|
||||
echo "[i] Firewall rules applied successfully"
|
||||
else
|
||||
echo "[e] Failed to apply firewall rules"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
setup
|
||||
case "${1:-}" in
|
||||
--enable)
|
||||
wait_for_network
|
||||
nft_mullvad
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 --enable"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ---
|
||||
# @file_name: install_cradle.sh
|
||||
# @version: 1.0.0
|
||||
# @description: Install local scripts
|
||||
# @author: Jamie Albert (empty_produce)
|
||||
# @author_contact: <mailto:empty.produce@flatmail.me>
|
||||
# @license: GNU Affero General Public License v3.0 (Included in LICENSE)
|
||||
# Copyright (C) 2025, Jamie Albert
|
||||
# ---
|
||||
set -euo pipefail
|
||||
|
||||
declare -gr INSTALL_DIR="/usr/local/bin"
|
||||
declare -g SCRIPTS_DIR; SCRIPTS_DIR="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)/scripts"
|
||||
declare -g CONFIG_DIR; CONFIG_DIR="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)/config"
|
||||
declare -g DICT_DIR; DICT_DIR="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)/dict"
|
||||
declare -ga TOOLS=("pwgen.sh" "jade.sh" "jau.sh" "rclone_mount.sh")
|
||||
declare -gr JADE_CONFIG_DIR="/usr/local/etc/jade.sh"
|
||||
|
||||
# ---
|
||||
# @return_code: [2] Scripts directory not found.
|
||||
# @return_code: [3] Config directory not found.
|
||||
# @return_code: [4] Dict directory not found.
|
||||
# shellcheck disable=1090,1091
|
||||
# ---
|
||||
setup() {
|
||||
. /usr/local/share/dao/libs/libs_dao.sh
|
||||
[[ -d $INSTALL_DIR ]] || sudo mkdir -p "$INSTALL_DIR" || dao::error 1 "Failed to create installation directory $INSTALL_DIR"
|
||||
[[ -d "${SCRIPTS_DIR}" ]] || dao::error 2 "Scripts directory not found: ${SCRIPTS_DIR}"
|
||||
[[ -d "${CONFIG_DIR}" ]] || dao::error 3 "Config directory not found: ${CONFIG_DIR}"
|
||||
[[ -d "${DICT_DIR}" ]] || dao::error 4 "Dict directory not found: ${DICT_DIR}"
|
||||
}
|
||||
|
||||
# ---
|
||||
# @arg: $1 - The name of the tool/script to install.
|
||||
# @return_code: [1] General dao::error (inherits from set -e).
|
||||
# @return_code: [5] Source file not found.
|
||||
# @return_code: [6] Copy failed for the tool.
|
||||
# @return_code: [7] chmod failed for the tool.
|
||||
# @return_code: [8] Failed to create jade config directory.
|
||||
# @return_code: [9] Failed to copy config for jade.sh.
|
||||
# @return_code: [10] Config template not found for jade.sh.
|
||||
# @return_code: [11] Copy failed for pwgen.list.
|
||||
# ---
|
||||
install_tool() {
|
||||
declare tool="$1"
|
||||
declare src_path
|
||||
src_path=$(realpath "${SCRIPTS_DIR}/${tool}")
|
||||
|
||||
[[ -f $src_path ]] || dao::error 5 "Source file not found: $tool"
|
||||
|
||||
sudo rm -f "${INSTALL_DIR}/${tool}"
|
||||
sudo ln -s "$src_path" "$INSTALL_DIR/" || dao::error 6 "Copy failed for $tool"
|
||||
sudo chmod 755 "$INSTALL_DIR/$tool" || dao::error 7 "chmod failed for $tool"
|
||||
dao::info "Installed: $INSTALL_DIR/$tool"
|
||||
|
||||
case ${tool} in
|
||||
pwgen.sh)
|
||||
declare dict_src="${DICT_DIR}/pwgen.list"
|
||||
if [[ -f "${dict_src}" ]]; then
|
||||
sudo rm -f /usr/share/dict/pwgen.list
|
||||
sudo ln -s "${dict_src}" /usr/share/dict/ || dao::error 11 "Copy failed for pwgen.list"
|
||||
dao::info "Installed /usr/share/dict/pwgen.list"
|
||||
else
|
||||
dao::warn "Dict file not found at '${dict_src}', skipping installation of /usr/share/dict/pwgen.list"
|
||||
fi
|
||||
;;
|
||||
jade.sh)
|
||||
declare jade_config_src="${CONFIG_DIR}/jade.conf"
|
||||
declare jade_config_dest="${JADE_CONFIG_DIR}/jade.conf"
|
||||
if [[ -f "${jade_config_src}" ]]; then
|
||||
if [[ ! -f "${jade_config_dest}" ]]; then
|
||||
sudo mkdir -p "${JADE_CONFIG_DIR}" || dao::error 8 "Failed to create jade config directory"
|
||||
sudo rm -f "${jade_config_dest}"
|
||||
sudo ln -s "${jade_config_src}" "${jade_config_dest}" || dao::error 9 "Failed to copy config for jade.sh"
|
||||
dao::info "Installed ${jade_config_dest} - manually set variables within this file."
|
||||
else
|
||||
dao::info "${jade_config_dest} already exists, not overwriting."
|
||||
fi
|
||||
else
|
||||
dao::error 10 "Config template not found: '${jade_config_src}'"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
setup
|
||||
|
||||
declare tool
|
||||
for tool in "${TOOLS[@]}"; do
|
||||
install_tool "$tool"
|
||||
done
|
||||
|
||||
dao::info "All tools installed successfully."
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,115 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ---
|
||||
# @file_name: jade.sh
|
||||
# @version: 1.3.1
|
||||
# @description: Lazy script for modifying docker files
|
||||
# @author: Jamie Albert (empty_produce)
|
||||
# @author_contact: <mailto:empty.produce@flatmail.me>
|
||||
# @license: GNU Affero General Public License v3.0 (Included in LICENSE)
|
||||
# Copyright (C) 2025, Jamie Albert
|
||||
# ---
|
||||
set -euo pipefail
|
||||
|
||||
# ---
|
||||
# shellcheck disable=1091
|
||||
# ---
|
||||
setup() {
|
||||
. /usr/local/share/dao/libs/libs_dao.sh
|
||||
. /usr/local/share/dao/config/dao.conf
|
||||
}
|
||||
|
||||
# ---
|
||||
# @return_code: [3] Download failed.
|
||||
# ---
|
||||
download_file() {
|
||||
scp -q "${JADE_REMOTE_HOST}:${JADE_REMOTE_PATH}" "$JADE_LOCAL_PATH" || dao::error 3 'Download failed'
|
||||
dao::info "Downloaded: $JADE_LOCAL_PATH"
|
||||
}
|
||||
|
||||
# ---
|
||||
# @return_code: [4] Local file missing.
|
||||
# @return_code: [5] Failed to create remote backup.
|
||||
# @return_code: [6] Upload failed.
|
||||
# ---
|
||||
upload_file() {
|
||||
[[ -f "$JADE_LOCAL_PATH" ]] || dao::error 4 "Local file missing: $JADE_LOCAL_PATH"
|
||||
ssh -q "${JADE_REMOTE_HOST}" "[[ -f '${JADE_REMOTE_PATH}' ]] && cp -f '${JADE_REMOTE_PATH}' '${JADE_REMOTE_PATH}.bak'" || dao::error 5 'Failed to create remote backup'
|
||||
scp -q "$JADE_LOCAL_PATH" "${JADE_REMOTE_HOST}:${JADE_REMOTE_PATH}" || dao::error 6 'Upload failed'
|
||||
dao::info "Uploaded: $JADE_LOCAL_PATH"
|
||||
dao::info "Remote file backed up to: ${JADE_REMOTE_PATH}.bak"
|
||||
}
|
||||
|
||||
# ---
|
||||
# @return_code: [7] JADE_EDITOR command not found.
|
||||
# @return_code: [3] Download failed (inherited from download_file).
|
||||
# ---
|
||||
edit_file() {
|
||||
download_file
|
||||
if ! command -v "$JADE_EDITOR" >/dev/null; then
|
||||
dao::error 7 "JADE_EDITOR not found: '$JADE_EDITOR'"
|
||||
fi
|
||||
"$JADE_EDITOR" "$JADE_LOCAL_PATH"
|
||||
}
|
||||
|
||||
# ---
|
||||
# @return_code: [6] Upload failed (inherited from upload_file).
|
||||
# @return_code: [8] Remote docker compose up failed.
|
||||
# ---
|
||||
upload_compose() {
|
||||
upload_file
|
||||
ssh -q "${JADE_REMOTE_HOST}" \
|
||||
"cd '$(dirname "$JADE_REMOTE_PATH")' && exec docker compose up -d --remove-orphans" \
|
||||
|| dao::error 8 'Remote docker compose up failed'
|
||||
dao::info 'Remote docker compose up -d completed'
|
||||
}
|
||||
|
||||
# ---
|
||||
# @return_code: [9] Remote docker compose down failed.
|
||||
# @return_code: [6] Upload failed (inherited from upload_file).
|
||||
# @return_code: [11] Remote docker compose up failed during restart.
|
||||
# ---
|
||||
upload_restart() {
|
||||
ssh -q "${JADE_REMOTE_HOST}" \
|
||||
"cd '$(dirname "$JADE_REMOTE_PATH")' && exec docker compose down" \
|
||||
|| dao::error 9 'Remote docker compose down failed'
|
||||
upload_file
|
||||
ssh -q "${JADE_REMOTE_HOST}" \
|
||||
"cd '$(dirname "$JADE_REMOTE_PATH")' && exec docker compose up -d --remove-orphans" \
|
||||
|| dao::error 11 'Remote docker compose up failed during restart'
|
||||
dao::info 'Remote docker compose restart completed'
|
||||
}
|
||||
|
||||
# ---
|
||||
# @return_code: [10] Unknown command-line option.
|
||||
# @return_code: [12] Required tool 'scp' not found.
|
||||
# @return_code: [13] Required tool 'ssh' not found.
|
||||
# @return_code: [14] Unexpected execution mode.
|
||||
# @return_code: [N] Errors from called functions (e.g., download_file, upload_file, etc.).
|
||||
# ---
|
||||
main() {
|
||||
setup
|
||||
declare mode=''
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-d) mode='download' ; shift ;;
|
||||
-u) mode='upload' ; shift ;;
|
||||
-uc) mode='up' ; shift ;;
|
||||
-ur) mode='restart' ; shift ;;
|
||||
*) dao::error 10 "Unknown option: $1 (use -d, -u, -uc, -ur)" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
command -v scp >/dev/null || dao::error 12 "'scp' not found"
|
||||
command -v ssh >/dev/null || dao::error 13 "'ssh' not found"
|
||||
|
||||
case "$mode" in
|
||||
download) download_file ;;
|
||||
upload) upload_file ;;
|
||||
up) upload_compose ;;
|
||||
restart) upload_restart ;;
|
||||
'') edit_file ;;
|
||||
*) dao::error 14 "Unexpected mode: $mode" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user