From f1e645289035cdeb290143742aa79038e6531731 Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Sun, 3 Jul 2022 11:47:40 +0200 Subject: [PATCH] move sepurator to variables and add that entrypoint.sh can run install script if you like to install more packages --- .bashrc | 28 +++++++++++++--------------- .gitignore | 3 +-- Dockerfile | 1 + entrypoint.sh | 20 +++++++++++++++----- variables.sh | 8 +++++++- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.bashrc b/.bashrc index 7f58206..ce2dbe2 100644 --- a/.bashrc +++ b/.bashrc @@ -16,10 +16,6 @@ export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e ############################################################################################################################## source "/variables.sh" -function sepurator { - echo "==============================================================================================" -} - function find_borg_repo { repo_list=( $(find "$1" -name "index.*" -type f | rev | cut -d '/' -f "2-" | rev) ) @@ -67,19 +63,21 @@ function select_borg_repo { } function ask_for_repo_password { - if grep -q 'key' "$BORG_REPO/config"; then - echo "* BORG REPO has a password" - sepurator - echo "(you can leave it empty if you not like to export BORG_PASSPHRASE)" - read -s -p "Please enter password: " BORG_REPO_PASSWORD - echo "" - if [ "$BORG_REPO_PASSWORD" != "" ]; then - export BORG_PASSPHRASE="$BORG_REPO_PASSWORD" + if [ -z "$BORG_PASSPHRASE" ]; then + if grep -q 'key' "$BORG_REPO/config"; then + echo "* BORG REPO has a password" + sepurator + echo "(you can leave it empty if you not like to export BORG_PASSPHRASE)" + read -s -p "Please enter password: " BORG_REPO_PASSWORD + echo "" + if [ "$BORG_REPO_PASSWORD" != "" ]; then + export BORG_PASSPHRASE="$BORG_REPO_PASSWORD" + fi + else + echo "* BORG REPO has no password" fi - else - echo "* BORG REPO has no password" + sepurator fi - sepurator } function print_container_info { diff --git a/.gitignore b/.gitignore index 54321b0..e8bf9f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -sshkeys/clients/ -sshkeys/host/ +sshkeys/ backups/ diff --git a/Dockerfile b/Dockerfile index 40344ef..4bd5914 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ ENV UID=1000 ENV GID=1000 ENV MAINTENANCE_ENABLE="false" ENV INTERACTIVE_MODE="false" +ENV RUN_INSTALL_SCRIPT="false" ENV TZ="" # Add Folders and Shell Scripts diff --git a/entrypoint.sh b/entrypoint.sh index 186db29..e43545e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,10 +3,6 @@ source "/variables.sh" ############################################################################################################################## # Funktionen ############################################################################################################################## -function sepurator { - echo "===============================================================================" -} - function print_container_info { sepurator echo "* BorgServer powered by $BORG_VERSION" @@ -117,7 +113,7 @@ function maintenance_enable { echo "" if [ -f "/crontab.txt" ]; then /usr/bin/crontab "/crontab.txt" - /usr/sbin/crond -b + /usr/sbin/crond -b 2> /dev/null echo "- Crontab loaded successfully" else echo "- Can not find /crontab.txt" @@ -135,6 +131,19 @@ function set_timezone { fi sepurator } + +function run_install_script { + if [ "$RUN_INSTALL_SCRIPT" != "false" ]; then + if [ ! -f "/.runnedInstall" ]; then + echo "* RUNNING INSTALL SCRIPT" + sepurator + sh "$RUN_INSTALL_SCRIPT" + echo "" + sepurator + touch "/.runnedInstall" + fi + fi +} ############################################################################################################################## # Main Code ############################################################################################################################## @@ -150,6 +159,7 @@ sepurator maintenance_enable set_timezone +run_install_script echo "* Init done! - Starting SSH-Daemon..." sepurator diff --git a/variables.sh b/variables.sh index f504de7..144ef5f 100644 --- a/variables.sh +++ b/variables.sh @@ -1,3 +1,9 @@ DOCKER_IMAGE_VERSION="1.0.9" BORG_VERSION=$(borg -V) -SSH_FOLDERS=( /sshkeys/clients /sshkeys/host ) +SSH_FOLDERS=( "/sshkeys/clients" "/sshkeys/host" ) +############################################################################################################################## +# Funktionen +############################################################################################################################## +function sepurator { + echo "======================================================================================" +}