mirror of
https://git.cloudron.io/cloudron/peertube-app.git
synced 2024-11-22 01:21:10 +00:00
Improve startup logic to make it more stable
This commit is contained in:
parent
b3895aab55
commit
8a6d5d5394
2 changed files with 63 additions and 58 deletions
|
@ -74,19 +74,19 @@ email:
|
||||||
|
|
||||||
# From the project root directory
|
# From the project root directory
|
||||||
storage:
|
storage:
|
||||||
tmp: '/var/www/peertube/storage/tmp/' # Use to download data (imports etc), store uploaded files before processing...
|
tmp: '/app/data/storage/tmp/' # Use to download data (imports etc), store uploaded files before processing...
|
||||||
avatars: '/var/www/peertube/storage/avatars/'
|
avatars: '/app/data/storage/avatars/'
|
||||||
videos: '/var/www/peertube/storage/videos/'
|
videos: '/app/data/storage/videos/'
|
||||||
streaming_playlists: '/var/www/peertube/storage/streaming-playlists/'
|
streaming_playlists: '/app/data/storage/streaming-playlists/'
|
||||||
redundancy: '/var/www/peertube/storage/redundancy/'
|
redundancy: '/app/data/storage/redundancy/'
|
||||||
logs: '/var/www/peertube/storage/logs/'
|
logs: '/app/data/storage/logs/'
|
||||||
previews: '/var/www/peertube/storage/previews/'
|
previews: '/app/data/storage/previews/'
|
||||||
thumbnails: '/var/www/peertube/storage/thumbnails/'
|
thumbnails: '/app/data/storage/thumbnails/'
|
||||||
torrents: '/var/www/peertube/storage/torrents/'
|
torrents: '/app/data/storage/torrents/'
|
||||||
captions: '/var/www/peertube/storage/captions/'
|
captions: '/app/data/storage/captions/'
|
||||||
cache: '/var/www/peertube/storage/cache/'
|
cache: '/app/data/storage/cache/'
|
||||||
plugins: '/var/www/peertube/storage/plugins/'
|
plugins: '/app/data/storage/plugins/'
|
||||||
client_overrides: '/var/www/peertube/storage/client-overrides/'
|
client_overrides: '/app/data/storage/client-overrides/'
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: 'info' # debug/info/warning/error
|
level: 'info' # debug/info/warning/error
|
||||||
|
|
95
start.sh
95
start.sh
|
@ -7,6 +7,13 @@ mkdir -p /app/data/storage
|
||||||
# do not rely on WORKDIR
|
# do not rely on WORKDIR
|
||||||
cd /app/code/server
|
cd /app/code/server
|
||||||
|
|
||||||
|
update_ldap() {
|
||||||
|
echo "==> Updating Ldap credentials"
|
||||||
|
|
||||||
|
PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} \
|
||||||
|
-c "UPDATE plugin SET settings='{\"url\": \"${CLOUDRON_LDAP_URL}\", \"weight\": 100, \"insecure-tls\": false, \"bind-dn\": \"${CLOUDRON_LDAP_BIND_DN}\", \"bind-credentials\": \"${CLOUDRON_LDAP_BIND_PASSWORD}\", \"search-base\": \"${CLOUDRON_LDAP_USERS_BASE_DN}\", \"mail-property\": \"mail\", \"search-filter\": \"(|(mail={{username}})(username={{username}}))\", \"username-property\": \"username\"}' WHERE name='auth-ldap'"
|
||||||
|
}
|
||||||
|
|
||||||
first_time_setup() {
|
first_time_setup() {
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
|
@ -21,14 +28,46 @@ first_time_setup() {
|
||||||
if [[ -n "${CLOUDRON_LDAP_SERVER:-}" ]]; then
|
if [[ -n "${CLOUDRON_LDAP_SERVER:-}" ]]; then
|
||||||
echo "==> Installing LDAP plugin"
|
echo "==> Installing LDAP plugin"
|
||||||
cd /app/code/cli && node dist/server/tools/peertube.js plugins install -n peertube-plugin-auth-ldap --url "${CLOUDRON_APP_ORIGIN}" --username root --password changeme
|
cd /app/code/cli && node dist/server/tools/peertube.js plugins install -n peertube-plugin-auth-ldap --url "${CLOUDRON_APP_ORIGIN}" --username root --password changeme
|
||||||
|
update_ldap
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_ldap() {
|
update_config() {
|
||||||
echo "==> Updating Ldap credentials"
|
echo "==> Ensure and updating configs"
|
||||||
|
|
||||||
PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} \
|
yq eval ".webserver.hostname = \"${CLOUDRON_APP_DOMAIN}\"" -i /app/data/production.yaml
|
||||||
-c "UPDATE plugin SET settings='{\"url\": \"${CLOUDRON_LDAP_URL}\", \"weight\": 100, \"insecure-tls\": false, \"bind-dn\": \"${CLOUDRON_LDAP_BIND_DN}\", \"bind-credentials\": \"${CLOUDRON_LDAP_BIND_PASSWORD}\", \"search-base\": \"${CLOUDRON_LDAP_USERS_BASE_DN}\", \"mail-property\": \"mail\", \"search-filter\": \"(|(mail={{username}})(username={{username}}))\", \"username-property\": \"username\"}' WHERE name='auth-ldap'"
|
|
||||||
|
# database
|
||||||
|
yq eval ".database.hostname = \"${CLOUDRON_POSTGRESQL_HOST}\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".database.port = ${CLOUDRON_POSTGRESQL_PORT}" -i /app/data/production.yaml
|
||||||
|
yq eval ".database.username = \"${CLOUDRON_POSTGRESQL_USERNAME}\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".database.password = \"${CLOUDRON_POSTGRESQL_PASSWORD}\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".database.name = \"${CLOUDRON_POSTGRESQL_DATABASE}\"" -i /app/data/production.yaml
|
||||||
|
yq eval "del(.database.suffix)" -i /app/data/production.yaml
|
||||||
|
|
||||||
|
# redis
|
||||||
|
yq eval ".redis.hostname = \"${CLOUDRON_REDIS_HOST}\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".redis.port = ${CLOUDRON_REDIS_PORT}" -i /app/data/production.yaml
|
||||||
|
yq eval ".redis.auth = \"${CLOUDRON_REDIS_PASSWORD}\"" -i /app/data/production.yaml
|
||||||
|
|
||||||
|
# smtp
|
||||||
|
yq eval ".smtp.hostname = \"${CLOUDRON_MAIL_SMTP_SERVER}\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".smtp.port = ${CLOUDRON_MAIL_SMTP_PORT}" -i /app/data/production.yaml
|
||||||
|
yq eval ".smtp.username = \"${CLOUDRON_MAIL_SMTP_USERNAME}\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".smtp.password = \"${CLOUDRON_MAIL_SMTP_PASSWORD}\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".smtp.tls = false" -i /app/data/production.yaml
|
||||||
|
yq eval ".smtp.disable_starttls = true" -i /app/data/production.yaml
|
||||||
|
yq eval ".smtp.from_address = \"${CLOUDRON_MAIL_FROM}\"" -i /app/data/production.yaml
|
||||||
|
|
||||||
|
echo "==> Migrate config file attributes for v4"
|
||||||
|
# v4 config file migrations https://github.com/Chocobozzz/PeerTube/releases/tag/v4.0.0
|
||||||
|
yq eval "del(.log.rotation.maxFileSize)" -i /app/data/production.yaml
|
||||||
|
yq eval "del(.log.rotation.maxFiles)" -i /app/data/production.yaml
|
||||||
|
yq eval "del(.log.anonymizeIP)" -i /app/data/production.yaml
|
||||||
|
yq eval ".log.rotation.max_file_size = \"1MB\"" -i /app/data/production.yaml
|
||||||
|
yq eval ".log.rotation.max_files = 1" -i /app/data/production.yaml
|
||||||
|
yq eval ".log.anonymizeIP = false" -i /app/data/production.yaml
|
||||||
|
yq eval ".storage.bin = \"/app/data/storage/bin/\"" -i /app/data/production.yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
# cd /var/www/peertube/peertube-latest/scripts && sudo -H -u peertube ./upgrade.sh
|
# cd /var/www/peertube/peertube-latest/scripts && sudo -H -u peertube ./upgrade.sh
|
||||||
|
@ -36,51 +75,17 @@ if [[ ! -f "/app/data/production.yaml" ]]; then
|
||||||
echo "==> First run. creating config"
|
echo "==> First run. creating config"
|
||||||
cp /app/pkg/production.yaml.example /app/data/production.yaml
|
cp /app/pkg/production.yaml.example /app/data/production.yaml
|
||||||
|
|
||||||
# this is sed because there are too many paths
|
update_config
|
||||||
sed -e 's,/var/www/peertube/storage,/app/data/storage,g' -i /app/data/production.yaml
|
first_time_setup &
|
||||||
|
|
||||||
(first_time_setup && update_ldap) &
|
|
||||||
else
|
else
|
||||||
|
update_config
|
||||||
|
|
||||||
[[ -n "${CLOUDRON_LDAP_SERVER:-}" ]] && update_ldap
|
[[ -n "${CLOUDRON_LDAP_SERVER:-}" ]] && update_ldap
|
||||||
|
|
||||||
|
echo "==> Migrate HLS paths to new for v4"
|
||||||
|
node dist/scripts/migrations/peertube-4.0.js
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "==> Updating configs"
|
|
||||||
yq eval ".webserver.hostname = \"${CLOUDRON_APP_DOMAIN}\"" -i /app/data/production.yaml
|
|
||||||
|
|
||||||
# database
|
|
||||||
yq eval ".database.hostname = \"${CLOUDRON_POSTGRESQL_HOST}\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".database.port = ${CLOUDRON_POSTGRESQL_PORT}" -i /app/data/production.yaml
|
|
||||||
yq eval ".database.username = \"${CLOUDRON_POSTGRESQL_USERNAME}\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".database.password = \"${CLOUDRON_POSTGRESQL_PASSWORD}\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".database.name = \"${CLOUDRON_POSTGRESQL_DATABASE}\"" -i /app/data/production.yaml
|
|
||||||
yq eval "del(.database.suffix)" -i /app/data/production.yaml
|
|
||||||
|
|
||||||
# redis
|
|
||||||
yq eval ".redis.hostname = \"${CLOUDRON_REDIS_HOST}\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".redis.port = ${CLOUDRON_REDIS_PORT}" -i /app/data/production.yaml
|
|
||||||
yq eval ".redis.auth = \"${CLOUDRON_REDIS_PASSWORD}\"" -i /app/data/production.yaml
|
|
||||||
|
|
||||||
# smtp
|
|
||||||
yq eval ".smtp.hostname = \"${CLOUDRON_MAIL_SMTP_SERVER}\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".smtp.port = ${CLOUDRON_MAIL_SMTP_PORT}" -i /app/data/production.yaml
|
|
||||||
yq eval ".smtp.username = \"${CLOUDRON_MAIL_SMTP_USERNAME}\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".smtp.password = \"${CLOUDRON_MAIL_SMTP_PASSWORD}\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".smtp.tls = false" -i /app/data/production.yaml
|
|
||||||
yq eval ".smtp.disable_starttls = true" -i /app/data/production.yaml
|
|
||||||
yq eval ".smtp.from_address = \"${CLOUDRON_MAIL_FROM}\"" -i /app/data/production.yaml
|
|
||||||
|
|
||||||
# v4 config file migrations https://github.com/Chocobozzz/PeerTube/releases/tag/v4.0.0
|
|
||||||
yq eval "del(.log.rotation.maxFileSize)" -i /app/data/production.yaml
|
|
||||||
yq eval "del(.log.rotation.maxFiles)" -i /app/data/production.yaml
|
|
||||||
yq eval "del(.log.anonymizeIP)" -i /app/data/production.yaml
|
|
||||||
yq eval ".log.rotation.max_file_size = \"1MB\"" -i /app/data/production.yaml
|
|
||||||
yq eval ".log.rotation.max_files = 1" -i /app/data/production.yaml
|
|
||||||
yq eval ".log.anonymizeIP = false" -i /app/data/production.yaml
|
|
||||||
yq eval ".storage.bin = \"/app/data/storage/bin/\"" -i /app/data/production.yaml
|
|
||||||
|
|
||||||
echo "==> Migrate HLS paths to new for v4"
|
|
||||||
node dist/scripts/migrations/peertube-4.0.js
|
|
||||||
|
|
||||||
chown -R cloudron:cloudron /app/data
|
chown -R cloudron:cloudron /app/data
|
||||||
|
|
||||||
echo "==> Starting PeerTube"
|
echo "==> Starting PeerTube"
|
||||||
|
|
Loading…
Reference in a new issue