perf: removal of firewall
This commit is contained in:
@@ -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 "$@"
|
||||
@@ -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 "$@"
|
||||
|
||||
Reference in New Issue
Block a user