diff --git a/.env b/.env deleted file mode 100644 index e85c75c..0000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -TEST_PASSWORD=Pi9Y8hap63ReAAsH6nxj -TEST_PASSWORD2=4266742@gmail.com -TEST_PASSWORD2r=4266742@gmail.com -TEST_PASSWORD2rr=sU9Dtf6v6qDlVsYaijqu diff --git a/env-gen-all.sh b/env-gen-all.sh new file mode 100644 index 0000000..e8c249d --- /dev/null +++ b/env-gen-all.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Use: $0 ENV_FILE VARIABLE_NAME (VALUE)" + exit 1 +fi + +ENV_FILE=$1 +VARIABLE_NAME=$2 + +# Password gen: 20chars,0-9,a-z +generate_random_password() { + #tr -dc 'a-z0-9' > "$ENV_FILE" +fi + +trap - ERR +echo "Variable $VARIABLE_NAME successfully updated/added to $ENV_FILE" \ No newline at end of file diff --git a/env-gen.sh b/env-gen.sh index 33e83a5..a3b58e4 100644 --- a/env-gen.sh +++ b/env-gen.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ -z "$1" ]; then - echo "Use: $0 [value]" + echo "Use: $0 VARIABLE_NAME (VALUE)" exit 1 fi @@ -14,27 +14,33 @@ generate_random_password() { pwgen -s 20 1 } -# If the second parameter is specified, use it as the value of the variable +trap 'echo -e "\033[31menv-gen.sh: Something went wrong\033[0m"; exit 1' ERR +set -e + +export DEBIAN_FRONTEND=noninteractive + +echo "If the second parameter is specified, use it as the value of the variable..." if [ -n "$2" ]; then VALUE=$2 else VALUE=$(generate_random_password) fi -# Creating .env file if it doesn't exist +echo "Creating .env file if it doesn't exist..." if [ ! -f "$ENV_FILE" ]; then - # Creating directories if they don't exist + echo "# Creating directories if they don't exist..." mkdir -p "$(dirname "$ENV_FILE")" touch "$ENV_FILE" fi -# Update or add a variable to the .env file +echo "Update or add a variable to the .env file" if grep -q "^$VARIABLE_NAME=" "$ENV_FILE"; then - # The variable exists, update its value + echo "The variable exists, update its value..." sed -i "s/^$VARIABLE_NAME=.*/$VARIABLE_NAME=$VALUE/" "$ENV_FILE" else - # The variable does not exist, add it to the file + echo "The variable does not exist, add it to the file..." echo "$VARIABLE_NAME=$VALUE" >> "$ENV_FILE" fi +trap - ERR echo "Variable $VARIABLE_NAME successfully updated/added to $ENV_FILE" \ No newline at end of file diff --git a/global-env.sh b/global-env.sh index 0599a3c..eacbcc9 100644 --- a/global-env.sh +++ b/global-env.sh @@ -10,7 +10,7 @@ if [ -z "$1" ] || [ -z "$2" ]; then exit 1 fi -trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT +trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' ERR set -e export DEBIAN_FRONTEND=noninteractive @@ -34,6 +34,6 @@ fi export "${ENV_VAR_NAME}=${ENV_VAR_VALUE}" -trap - EXIT +trap - ERR echo "Environment variable ${ENV_VAR_NAME} set to:" printenv "${ENV_VAR_NAME}" \ No newline at end of file diff --git a/init-docker.sh b/init-docker.sh index 9a86d03..82f92a2 100644 --- a/init-docker.sh +++ b/init-docker.sh @@ -5,7 +5,7 @@ if [ "$(id -u)" != "0" ]; then exit 0 fi -trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT +trap 'echo -e "\033[31minit-docker.sh: Something went wrong\033[0m"; exit 1' ERR set -e export DEBIAN_FRONTEND=noninteractive @@ -16,5 +16,8 @@ add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu apt-get update -y apt-get install -y docker-ce -trap - EXIT +echo "Creating docker network proxynet..." +docker network create proxynet + +trap - ERR echo "Docker installed" \ No newline at end of file diff --git a/readme/samba.md b/readme/samba.md new file mode 100644 index 0000000..7233ec7 --- /dev/null +++ b/readme/samba.md @@ -0,0 +1,31 @@ + +### Samba + +**Установка:** + +`sudo bash init-samba.sh USERNAME PASSWORD` + +**Подключение в Wondows:** + +`net use Z: \\dev.dd\data` + +Это подключит общую папку как сетевой диск `Z:`. + + +#### Решение проблем с подключением к серверу в Windows: + +**Удалить samba подключение в windows:** + +`net use \\wd.hm\data /delete` + + +**Для перезапуска Samba клиента в Windows 10, вы можете выполнить следующие шаги:** + +1. **Остановите службу `Workstation` (Рабочая станция):** + - Нажмите `Win + R`, чтобы открыть окно «Выполнить». + - Введите `services.msc` и нажмите `Enter`, чтобы открыть окно «Службы». + - Найдите в списке служб службу «Workstation» (или «Рабочая станция» на русском). + - Щелкните правой кнопкой мыши по службе и выберите «Остановить». + +2. **Запустите службу `Workstation` заново:** + - Щелкните правой кнопкой мыши по службе «Workstation» и выберите «Запустить». diff --git a/samba.sh b/samba.sh index e798f97..fb49f34 100644 --- a/samba.sh +++ b/samba.sh @@ -42,22 +42,23 @@ NEW_SECTION=$(cat << EOM path = /data read only = no browseable = yes - create mask = 0666 - force create mode = 0666 + create mask = 0777 + force create mode = 0777 directory mask = 0777 force directory mode = 0777 - valid users = $USERNAME - -# backups folder access + force user = root + force group = root + [backups] path = /backups read only = no browseable = yes - create mask = 0666 - force create mode = 0666 + create mask = 0777 + force create mode = 0777 directory mask = 0777 force directory mode = 0777 - valid users = $USERNAME + force user = root + force group = root EOM ) @@ -77,4 +78,4 @@ echo "Samba configuration updated and saved to $SMB_CONF." systemctl restart smbd nmbd trap - EXIT -echo "Samba configured complete." \ No newline at end of file +echo "Samba configured complete."