autocommit
This commit is contained in:
parent
22981eac7f
commit
7172863cc1
4
.env
4
.env
@ -1,4 +0,0 @@
|
||||
TEST_PASSWORD=Pi9Y8hap63ReAAsH6nxj
|
||||
TEST_PASSWORD2=4266742@gmail.com
|
||||
TEST_PASSWORD2r=4266742@gmail.com
|
||||
TEST_PASSWORD2rr=sU9Dtf6v6qDlVsYaijqu
|
46
env-gen-all.sh
Normal file
46
env-gen-all.sh
Normal file
@ -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' </dev/urandom | head -c 20
|
||||
pwgen -s 20 1
|
||||
}
|
||||
|
||||
trap 'echo -e "\033[31menv-gen-all.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 "$3" ]; then
|
||||
VALUE=$3
|
||||
else
|
||||
VALUE=$(generate_random_password)
|
||||
fi
|
||||
|
||||
echo "Creating .env file if it doesn't exist..."
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "# Creating directories if they don't exist..."
|
||||
mkdir -p "$(dirname "$ENV_FILE")"
|
||||
touch "$ENV_FILE"
|
||||
fi
|
||||
|
||||
echo "Update or add a variable to the .env file"
|
||||
if grep -q "^$VARIABLE_NAME=" "$ENV_FILE"; then
|
||||
echo "The variable exists, update its value..."
|
||||
sed -i "s/^${VARIABLE_NAME//\//\\/}=.*/${VARIABLE_NAME//\//\\/}=${VALUE//\//\\/}/" "$ENV_FILE"
|
||||
else
|
||||
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"
|
20
env-gen.sh
20
env-gen.sh
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Use: $0 <var_name> [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"
|
@ -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}"
|
@ -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"
|
31
readme/samba.md
Normal file
31
readme/samba.md
Normal file
@ -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» и выберите «Запустить».
|
15
samba.sh
15
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
|
||||
force user = root
|
||||
force group = root
|
||||
|
||||
# backups folder access
|
||||
[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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user