first progress
This commit is contained in:
69
setup
Executable file
69
setup
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ENV_FILE=".env"
|
||||
|
||||
prompt_value() {
|
||||
local var_name="$1"
|
||||
local prompt_text="$2"
|
||||
local is_secret="${3:-false}"
|
||||
local value=""
|
||||
|
||||
while [[ -z "$value" ]]; do
|
||||
if [[ "$is_secret" == "true" ]]; then
|
||||
read -r -s -p "$prompt_text: " value
|
||||
printf "\n"
|
||||
else
|
||||
read -r -p "$prompt_text: " value
|
||||
fi
|
||||
done
|
||||
|
||||
printf -v "$var_name" '%s' "$value"
|
||||
}
|
||||
|
||||
write_env_file() {
|
||||
local realm=""
|
||||
local workgroup=""
|
||||
local domain=""
|
||||
local join_user=""
|
||||
local join_password=""
|
||||
|
||||
prompt_value realm "REALM (e.g. EXAMPLE.COM)"
|
||||
prompt_value workgroup "WORKGROUP (NetBIOS, e.g. EXAMPLE)"
|
||||
prompt_value domain "DOMAIN (AD DNS name or reachable DC FQDN)"
|
||||
prompt_value join_user "JOIN_USER (AD account with join rights)"
|
||||
prompt_value join_password "JOIN_PASSWORD" true
|
||||
|
||||
cat > "$ENV_FILE" <<EOF
|
||||
REALM=${realm}
|
||||
WORKGROUP=${workgroup}
|
||||
DOMAIN=${domain}
|
||||
JOIN_USER=${join_user}
|
||||
JOIN_PASSWORD=${join_password}
|
||||
PUBLIC_GROUP=Domain Users
|
||||
# SAMBA_HOSTNAME=ad-samba-file-server
|
||||
# Optional overrides:
|
||||
# LDAP_URI=ldaps://${domain}
|
||||
# LDAP_BASE_DN=DC=example,DC=com
|
||||
EOF
|
||||
|
||||
chmod 600 "$ENV_FILE"
|
||||
printf "Created %s\n" "$ENV_FILE"
|
||||
}
|
||||
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
read -r -p ".env already exists. Overwrite? [y/N]: " overwrite
|
||||
case "$overwrite" in
|
||||
y|Y|yes|YES)
|
||||
write_env_file
|
||||
;;
|
||||
*)
|
||||
printf "Keeping existing .env\n"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
write_env_file
|
||||
fi
|
||||
|
||||
docker compose up -d
|
||||
printf "Samba service started.\n"
|
||||
Reference in New Issue
Block a user