From 42fdbf28321de74103e15851cab850435b550b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Tue, 17 Jun 2025 17:00:43 +0200 Subject: [PATCH] feat: add common.sh file and initialize install.sh --- install.sh | 14 +++++++++++++- scripts/common.sh | 17 +++++++++++++++++ scripts/docker-compose.yml | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 scripts/common.sh diff --git a/install.sh b/install.sh index cc1f786..1572219 100644 --- a/install.sh +++ b/install.sh @@ -1 +1,13 @@ -#!/bin/bash \ No newline at end of file +#!/bin/bash + +source "./scripts/common.sh" + +if [[ $EUID -ne 0 ]]; then + echo "the script needs to be as root." + exit 1 +fi + +# if [ ! -d "$ENV_DIR" ]; then +# echo "$ENV_DIR is missing..., " +# mkdir -p $ENV_DIR +# fi \ No newline at end of file diff --git a/scripts/common.sh b/scripts/common.sh new file mode 100644 index 0000000..61ab9df --- /dev/null +++ b/scripts/common.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +FILENAME="serverconfig" + +ENV_DIR="/etc/$FILENAME" +ENV_FILE="$ENV_DIR/.env" +LOG="/var/log/$FILENAME.log" + +DATETIME_FORMAT="%d-%m-%Y %H:%M:%S" + +datetime_print() { + local message="$1" + local level="${2:-INFO}" + local timestamp="[$(date +"$DATETIME_FORMAT")]" + + echo "$timestamp - $level: $message" | tee -a "$LOG" +} \ No newline at end of file diff --git a/scripts/docker-compose.yml b/scripts/docker-compose.yml index 7a36b4f..2857765 100644 --- a/scripts/docker-compose.yml +++ b/scripts/docker-compose.yml @@ -1,6 +1,7 @@ volumes: etc_wireguard: etc_certs: + # save certifcate etc_acme: services: