Improve startup script
This commit is contained in:
parent
85cabaca34
commit
a2ec20e490
5 changed files with 53 additions and 56 deletions
|
@ -45,7 +45,7 @@ services:
|
|||
volumes:
|
||||
- ${PWD}/state:/app/state
|
||||
ports:
|
||||
- 3300:3000
|
||||
- 3000:3000
|
||||
networks:
|
||||
- tipi_main_network
|
||||
# labels:
|
||||
|
|
|
@ -3,16 +3,6 @@ set -e # Exit immediately if a command exits with a non-zero status.
|
|||
|
||||
ROOT_FOLDER="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
|
||||
|
||||
# Constants
|
||||
NGINX_PORT="80"
|
||||
# Apps
|
||||
APP_PI_HOLE_PORT="8081"
|
||||
APP_WG_EASY_PORT="8082"
|
||||
APP_NEXTCLOUD_PORT="8082"
|
||||
APP_ANONADDY_PORT="8083"
|
||||
APP_SIMPLETORRENT_PORT="8084"
|
||||
APP_FRESHRSS_PORT="8085"
|
||||
|
||||
echo
|
||||
echo "======================================"
|
||||
if [[ -f "${ROOT_FOLDER}/state/configured" ]]; then
|
||||
|
@ -32,34 +22,11 @@ if ! command -v ansible-playbook > /dev/null; then
|
|||
sudo pip3 install ansible
|
||||
fi
|
||||
|
||||
# Store paths to intermediary config files
|
||||
ENV_FILE="$ROOT_FOLDER/templates/.env"
|
||||
|
||||
# Remove intermediary config files
|
||||
[[ -f "$ENV_FILE" ]] && rm -f "$ENV_FILE"
|
||||
|
||||
# Copy template configs to intermediary configs
|
||||
[[ -f "$ROOT_FOLDER/templates/.env-sample" ]] && cp "$ROOT_FOLDER/templates/.env-sample" "$ENV_FILE"
|
||||
|
||||
echo "Generating config files..."
|
||||
for template in "${ENV_FILE}"; do
|
||||
sed -i "s/<nginx-port>/${NGINX_PORT}/g" "${template}"
|
||||
# Apps
|
||||
sed -i "s/<app-pi-hole-port>/${APP_PI_HOLE_PORT}/g" "${template}"
|
||||
sed -i "s/<app-wgeasy-port>/${APP_WG_EASY_PORT}/g" "${template}"
|
||||
sed -i "s/<app-nextcloud-port>/${APP_NEXTCLOUD_PORT}/g" "${template}"
|
||||
sed -i "s/<app-anonaddy-port>/${APP_ANONADDY_PORT}/g" "${template}"
|
||||
sed -i "s/<app-simpletorrent-port>/${APP_SIMPLETORRENT_PORT}/g" "${template}"
|
||||
sed -i "s/<app-freshrss-port>/${APP_FRESHRSS_PORT}/g" "${template}"
|
||||
done
|
||||
|
||||
ansible-playbook ansible/setup.yml -i ansible/hosts -K
|
||||
|
||||
mv -f "$ENV_FILE" "$ROOT_FOLDER/.env"
|
||||
|
||||
echo "Configuring permissions..."
|
||||
echo
|
||||
find "$ROOT_FOLDER" -path "$ROOT_FOLDER/app-data" -prune -o -exec chown 1000:1000 {} + || true
|
||||
# echo "Configuring permissions..."
|
||||
# echo
|
||||
# find "$ROOT_FOLDER" -path "$ROOT_FOLDER/app-data" -prune -o -exec chown 1000:1000 {} + || true
|
||||
|
||||
# Create configured status
|
||||
touch "${ROOT_FOLDER}/state/configured"
|
|
@ -10,12 +10,11 @@ fi
|
|||
|
||||
ROOT_FOLDER="$($readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
|
||||
STATE_FOLDER="${ROOT_FOLDER}/state"
|
||||
DOMAIN=local
|
||||
|
||||
INTERNAL_IP="$(hostname -I | awk '{print $1}')"
|
||||
PUID="$(id -u)"
|
||||
PGID="$(id -g)"
|
||||
TZ="$(cat /etc/timezone)"
|
||||
TZ="$(cat /etc/timezone | sed 's/\//\\\//g' || echo "Europe/Berlin")"
|
||||
|
||||
if [[ $UID != 0 ]]; then
|
||||
echo "Tipi must be started as root"
|
||||
|
@ -30,13 +29,17 @@ if [[ ! -f "${STATE_FOLDER}/configured" ]]; then
|
|||
fi
|
||||
|
||||
# Copy the app state if it isn't here
|
||||
if [[ ! -d "${STATE_FOLDER}/apps.json" ]]; then
|
||||
cp "${STATE_FOLDER}/apps.example.json" "${STATE_FOLDER}/apps.json"
|
||||
if [[ ! -f "${STATE_FOLDER}/apps.json" ]]; then
|
||||
cp "${ROOT_FOLDER}/templates/apps-sample.json" "${STATE_FOLDER}/apps.json"
|
||||
fi
|
||||
|
||||
export DOCKER_CLIENT_TIMEOUT=240
|
||||
export COMPOSE_HTTP_TIMEOUT=240
|
||||
|
||||
echo "Generating config files..."
|
||||
# Remove current .env file
|
||||
[[ -f "${ROOT_FOLDER}/.env" ]] && rm -f "${ROOT_FOLDER}/.env"
|
||||
|
||||
# Store paths to intermediary config files
|
||||
ENV_FILE="$ROOT_FOLDER/templates/.env"
|
||||
|
||||
|
@ -44,9 +47,9 @@ ENV_FILE="$ROOT_FOLDER/templates/.env"
|
|||
[[ -f "$ENV_FILE" ]] && rm -f "$ENV_FILE"
|
||||
|
||||
# Copy template configs to intermediary configs
|
||||
[[ -f "$ROOT_FOLDER/templates/.env-sample" ]] && cp "$ROOT_FOLDER/templates/.env-sample" "$ENV_FILE"
|
||||
[[ -f "$ROOT_FOLDER/templates/env-sample" ]] && cp "$ROOT_FOLDER/templates/env-sample" "$ENV_FILE"
|
||||
|
||||
echo "Generating config files..."
|
||||
echo $TZ
|
||||
for template in "${ENV_FILE}"; do
|
||||
sed -i "s/<internal_ip>/${INTERNAL_IP}/g" "${template}"
|
||||
sed -i "s/<puid>/${PUID}/g" "${template}"
|
||||
|
@ -64,21 +67,47 @@ docker-compose --env-file "${ROOT_FOLDER}/.env" up --detach --remove-orphans --b
|
|||
exit 1
|
||||
}
|
||||
|
||||
echo "Tipi is now running"
|
||||
echo "To stop it, run sudo ./scripts/stop.sh"
|
||||
echo "Visit http://${INTERNAL_IP}:3000 to view the dashboard"
|
||||
# Get field from json file
|
||||
# function get_json_field() {
|
||||
# local json_file="$1"
|
||||
# local field="$2"
|
||||
function get_json_field() {
|
||||
local json_file="$1"
|
||||
local field="$2"
|
||||
|
||||
# echo $(jq -r ".${field}" "${json_file}")
|
||||
# }
|
||||
echo $(jq -r ".${field}" "${json_file}")
|
||||
}
|
||||
|
||||
# str=$(get_json_field ${STATE_FOLDER}/apps.json installed)
|
||||
# apps_to_start=($str)
|
||||
str=$(get_json_field ${STATE_FOLDER}/apps.json installed)
|
||||
apps_to_start=($str)
|
||||
|
||||
for app in "${apps_to_start[@]}"; do
|
||||
"${ROOT_FOLDER}/scripts/app.sh" start $app
|
||||
done
|
||||
|
||||
echo "Tipi is now running"
|
||||
echo ""
|
||||
cat << "EOF"
|
||||
_,.
|
||||
,` -.)
|
||||
'( _/'-\\-.
|
||||
/,|`--._,-^| ,
|
||||
\_| |`-._/|| ,'|
|
||||
| `-, / | / /
|
||||
| || | / /
|
||||
`r-._||/ __ / /
|
||||
__,-<_ )`-/ `./ /
|
||||
' \ `---' \ / /
|
||||
| |./ /
|
||||
/ // /
|
||||
\_/' \ |/ /
|
||||
| | _,^-'/ /
|
||||
| , `` (\/ /_
|
||||
\,.->._ \X-=/^
|
||||
( / `-._//^`
|
||||
`Y-.____(__}
|
||||
| {__)
|
||||
()`
|
||||
EOF
|
||||
echo ""
|
||||
echo "Visit http://${INTERNAL_IP}:3000 to view the dashboard"
|
||||
echo ""
|
||||
|
||||
# for app in "${apps_to_start[@]}"; do
|
||||
# "${ROOT_FOLDER}/scripts/app.sh" start $app
|
||||
# done
|
||||
|
||||
|
|
1
templates/apps-sample.json
Normal file
1
templates/apps-sample.json
Normal file
|
@ -0,0 +1 @@
|
|||
{ "installed": "" }
|
Loading…
Add table
Reference in a new issue