2023-12-10 23:20:54 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-09-06 10:23:31 +00:00
|
|
|
set -e
|
|
|
|
|
2024-05-29 16:40:18 +00:00
|
|
|
source /etc/wireadmin/xscript.sh
|
2024-01-08 08:59:54 +00:00
|
|
|
|
2024-05-29 16:40:18 +00:00
|
|
|
ENV_FILE="/app/.env"
|
2024-01-08 08:59:54 +00:00
|
|
|
|
2023-12-11 01:43:05 +00:00
|
|
|
echo " "
|
|
|
|
echo " _ ___ ___ __ _ "
|
|
|
|
echo "| | / (_)_______ / | ____/ /___ ___ (_)___ "
|
|
|
|
echo "| | /| / / / ___/ _ \/ /| |/ __ / __ \`__ \/ / __ \\"
|
|
|
|
echo "| |/ |/ / / / / __/ ___ / /_/ / / / / / / / / / /"
|
|
|
|
echo "|__/|__/_/_/ \___/_/ |_\__,_/_/ /_/ /_/_/_/ /_/ "
|
|
|
|
echo " "
|
2023-12-11 00:36:15 +00:00
|
|
|
|
2024-05-29 16:40:18 +00:00
|
|
|
touch "$ENV_FILE"
|
|
|
|
chmod 400 "$ENV_FILE"
|
2023-11-01 16:43:26 +00:00
|
|
|
|
2024-05-29 16:40:18 +00:00
|
|
|
if [ -z "$ADMIN_PASSWORD" ]; then
|
|
|
|
log warn "No ADMIN_PASSWORD provided, using default password"
|
2023-11-01 16:43:26 +00:00
|
|
|
fi
|
2023-09-29 04:02:23 +00:00
|
|
|
|
2024-05-29 16:40:18 +00:00
|
|
|
# Remove duplicated envs
|
|
|
|
awk -F= '!a[$1]++' "$ENV_FILE" > "/tmp/$(basename "$ENV_FILE")" \
|
|
|
|
&& mv "/tmp/$(basename "$ENV_FILE")" "$ENV_FILE"
|
2023-09-29 04:02:23 +00:00
|
|
|
|
2024-01-08 08:59:54 +00:00
|
|
|
if [ -z "$WG_HOST" ]; then
|
2024-05-29 16:40:18 +00:00
|
|
|
log "error" "the WG_HOST environment variable is not set"
|
2024-01-08 08:59:54 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-12-19 09:51:23 +00:00
|
|
|
# Generate Tor configuration
|
2023-12-19 03:32:10 +00:00
|
|
|
generate_tor_config
|
2024-05-29 16:40:18 +00:00
|
|
|
setup_logrotate
|
|
|
|
setup_dns
|
|
|
|
|
|
|
|
# Background services
|
|
|
|
crond
|
|
|
|
dnsmasq
|
2023-12-11 00:36:15 +00:00
|
|
|
|
2024-05-29 16:40:18 +00:00
|
|
|
# Start Tor
|
|
|
|
screen -L -Logfile /var/log/wireadmin/tor.log -dmS tor \
|
|
|
|
bash -c "screen -S tor -X wrap off; tor -f $TOR_CONFIG"
|
2023-09-25 11:56:34 +00:00
|
|
|
|
2023-09-29 04:02:23 +00:00
|
|
|
sleep 1
|
2023-09-27 07:01:52 +00:00
|
|
|
echo -e "\n======================== Versions ========================"
|
2024-05-29 16:40:18 +00:00
|
|
|
echo -e "Alpine: \c" && cat /etc/alpine-release
|
|
|
|
echo -e "WireGuard: \c" && wg -v | head -n 1 | awk '{print $2}'
|
|
|
|
echo -e "Tor: \c" && tor --version | head -n 1 | awk '{print $3}' | sed 's/.$//'
|
|
|
|
echo -e "Dnsmasq: \c" && dnsmasq -v | head -n 1 | cut -d ' ' -f3
|
|
|
|
echo -e "Lyrebird: \c" && lyrebird -version
|
|
|
|
echo -e "\n======================= Tor Config ======================="
|
|
|
|
grep -v "^#" "$TOR_CONFIG"
|
|
|
|
echo -e "====================== Dnsmasq Config ======================"
|
|
|
|
grep -v "^#" "$DNSMASQ_CONFIG"
|
|
|
|
echo -e "==========================================================\n"
|
2023-09-29 04:02:23 +00:00
|
|
|
sleep 1
|
2023-09-25 23:31:07 +00:00
|
|
|
|
2023-09-06 10:23:31 +00:00
|
|
|
exec "$@"
|