mirror of
https://gitlab.com/Snogard/kaido.git
synced 2025-06-25 02:13:00 +02:00
100 lines
2.7 KiB
Bash
Executable File
100 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
source /opt/kaido/src/libs/bash/lib.sh
|
|
|
|
# setup
|
|
imageName_web=ghcr.io/linkwarden/linkwarden:v2.9.3
|
|
imageName_db=docker.io/library/postgres:16.8-alpine3.20
|
|
|
|
podName=linkwarden
|
|
|
|
containerName_web=${podName}_web
|
|
containerName_db=${podName}_db
|
|
|
|
envFile_db="$KAIDO_CONFIG_FOLDER/containers/$podName/$containerName_db.env"
|
|
envFile_web="$KAIDO_CONFIG_FOLDER/containers/$podName/$containerName_web.env"
|
|
|
|
dstBasePath="$KAIDO_CONTAINER_FOLDER/$podName"
|
|
dstPostgresDataPath="$dstBasePath/db"
|
|
dstLinkwardenDataPath="$dstBasePath/data"
|
|
|
|
secret_db_user=$containerName_db-postgres_user
|
|
secret_db_password=$containerName_db-postgres_password
|
|
secret_nextauth=$containerName_web-nextauth_secret
|
|
secret_db_url=$containerName_web-database_url
|
|
|
|
|
|
# envs
|
|
external_port=10120
|
|
db_name=linkwarden
|
|
disable_public_registration=true
|
|
|
|
|
|
if [ -f "$KAIDO_CONFIG_FOLDER/containers/$podName/envs.sh" ]; then
|
|
source "$KAIDO_CONFIG_FOLDER/containers/$podName/envs.sh"
|
|
fi
|
|
|
|
if [ ! -f "$envFile_db" ]; then
|
|
envFile_db=$KAIDO_EMPTY_ENV_FILE
|
|
fi
|
|
|
|
if [ ! -f "$envFile_web" ]; then
|
|
envFile_web=$KAIDO_EMPTY_ENV_FILE
|
|
fi
|
|
|
|
|
|
# pre install
|
|
create_folder "$dstPostgresDataPath"
|
|
create_folder "$dstLinkwardenDataPath"
|
|
stop_and_remove_pod $podName
|
|
|
|
res=0
|
|
secret_check $secret_db_user
|
|
res=$(($?+$res))
|
|
secret_check $secret_db_password
|
|
res=$(($?+$res))
|
|
secret_check $secret_db_url
|
|
res=$(($?+$res))
|
|
secret_check $secret_nextauth
|
|
res=$(($?+$res))
|
|
|
|
if [[ $res -gt 0 ]]; then
|
|
echo "[NOTE] $secret_db_url, must be in this format:
|
|
postgresql://[user]:[password]@$containerName_db:5432/$db_name
|
|
replace [user] with the same password you have used in $secret_db_user
|
|
replace [password] with the same password you have used in $secret_db_password"
|
|
|
|
exit 1
|
|
fi
|
|
|
|
#install
|
|
echo "Creating new $podName pod"
|
|
podman pod create \
|
|
--name $podName \
|
|
-p $external_port:3000/tcp \
|
|
|
|
echo "Creating new $containerName_db container"
|
|
podman create \
|
|
--pod $podName \
|
|
--name $containerName_db \
|
|
--secret $secret_db_user,type=env,target=POSTGRES_USER \
|
|
--secret $secret_db_password,type=env,target=POSTGRES_PASSWORD \
|
|
--env-file="$envFile_db" \
|
|
-e POSTGRES_DB=$db_name \
|
|
-v $dstPostgresDataPath:/var/lib/postgresql/data \
|
|
$imageName_db
|
|
|
|
echo "Creating new $containerName_web container"
|
|
podman create \
|
|
--pod $podName \
|
|
--name $containerName_web \
|
|
--requires $containerName_db \
|
|
--secret $secret_nextauth,type=env,target=NEXTAUTH_SECRET \
|
|
--secret $secret_db_url,type=env,target=DATABASE_URL \
|
|
--env-file="$envFile_web" \
|
|
-e NEXT_PUBLIC_DISABLE_REGISTRATION=$disable_public_registration \
|
|
-v $dstLinkwardenDataPath:/data/data \
|
|
$imageName_web
|
|
|
|
# systemd
|
|
create_systemd_services $podName
|
|
systemctl --user enable --now $podName |