diff --git a/scripts/backup.sh b/scripts/backup.sh index b8418f4..39292bd 100755 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/scripts/clear_data.sh b/scripts/clear_data.sh index c2e69bb..ac731b5 100755 --- a/scripts/clear_data.sh +++ b/scripts/clear_data.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + set -e cleanup_except() { @@ -22,9 +23,8 @@ cleanup_except() { done } -SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) -REPO_DIR=$(dirname $SCRIPT_DIR) -alias compose="compose -f $REPO_DIR/docker-compose.yml" +readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd) docker compose down diff --git a/scripts/create_password.sh b/scripts/create_password.sh index 3cc1310..9c67dcd 100755 --- a/scripts/create_password.sh +++ b/scripts/create_password.sh @@ -1,14 +1,16 @@ -#!/bin/bash +#!/usr/bin/env bash + set -e -SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) -REPO_DIR=$(dirname $SCRIPT_DIR) -alias compose="compose -f $REPO_DIR/docker-compose.yml" +readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd) echo "Please input the mosquitto password:" read -s MOSQUITTO_PASSWORD docker compose run -it --rm mqtt mosquitto_passwd -b -c /mosquitto/config/pwfile homeassistant $MOSQUITTO_PASSWORD +chown root:root $REPO_DIR/mosquitto/config/pwfile + echo "password: $MOSQUITTO_PASSWORD" > $REPO_DIR/zigbee2mqtt/secret.yaml chmod 600 $REPO_DIR/zigbee2mqtt/secret.yaml diff --git a/scripts/forget.sh b/scripts/forget.sh index 6347c52..e0df417 100755 --- a/scripts/forget.sh +++ b/scripts/forget.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash python -m restic.forget \ --keep-last 5 \ diff --git a/scripts/setup.sh b/scripts/setup.sh index f72ea3c..0474c52 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,12 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash set -e -SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) -REPO_DIR=$(dirname $SCRIPT_DIR) +readonly SCRIPT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) +readonly REPO_DIR=$(cd $(dirname $SCRIPT_DIR) && pwd) $SCRIPT_DIR/clear_data.sh $SCRIPT_DIR/create_password.sh -alias compose="compose -f $REPO_DIR/docker-compose.yml" docker compose up -d diff --git a/scripts/update.sh b/scripts/update.sh index 96b1cb1..de7f8ab 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e