Changed shebang
This commit is contained in:
parent
9a224e946a
commit
7d0ce6cfb1
2 changed files with 28 additions and 28 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/ash
|
#!/bin/sh
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
## This docker-entrypoint will take a copy of the configuration and install any
|
## This docker-entrypoint will take a copy of the configuration and install any
|
||||||
## envvars and then copy any required files into the /app/ directory next to any
|
## envvars and then copy any required files into the /app/ directory next to any
|
||||||
|
@ -19,35 +19,35 @@ envvars=("$MYSQL_ENV_MYSQL_USER" "$MYSQL_ENV_MYSQL_PASSWORD" "$MYSQL_ENV_MYSQL_D
|
||||||
function set_conf() {
|
function set_conf() {
|
||||||
case $1 in
|
case $1 in
|
||||||
$MYSQL_ENV_MYSQL_USER )
|
$MYSQL_ENV_MYSQL_USER )
|
||||||
/bin/ash echof info "Setting '$MYSQL_ENV_MYSQL_USER' $1 in /app/config/mysqlConfig.json"
|
echof info "Setting '$MYSQL_ENV_MYSQL_USER' $1 in /app/config/mysqlConfig.json"
|
||||||
sed -i 's/"username": "root"/"username": "'$MYSQL_ENV_MYSQL_USER'"/' /app/config/mysqlConfig.json
|
sed -i 's/"username": "root"/"username": "'$MYSQL_ENV_MYSQL_USER'"/' /app/config/mysqlConfig.json
|
||||||
;;
|
;;
|
||||||
$MYSQL_ENV_MYSQL_PASSWORD )
|
$MYSQL_ENV_MYSQL_PASSWORD )
|
||||||
## This echo should be sanitized of any secrets before this is finished.
|
## This echo should be sanitized of any secrets before this is finished.
|
||||||
/bin/ash echof info "Setting '$MYSQL_ENV_MYSQL_PASSWORD' $1 in /app/config/mysqlConfig.json"
|
echof info "Setting '$MYSQL_ENV_MYSQL_PASSWORD' $1 in /app/config/mysqlConfig.json"
|
||||||
sed -i 's/"password": ""/"password": "'$MYSQL_ENV_MYSQL_PASSWORD'"/' /app/config/mysqlConfig.json
|
sed -i 's/"password": ""/"password": "'$MYSQL_ENV_MYSQL_PASSWORD'"/' /app/config/mysqlConfig.json
|
||||||
;;
|
;;
|
||||||
$MYSQL_ENV_MYSQL_DATABASE )
|
$MYSQL_ENV_MYSQL_DATABASE )
|
||||||
/bin/ash echof info "Setting '$MYSQL_ENV_MYSQL_DATABASE' $1 in /app/config/mysqlConfig.json"
|
echof info "Setting '$MYSQL_ENV_MYSQL_DATABASE' $1 in /app/config/mysqlConfig.json"
|
||||||
sed -i 's/"database": "lbry"/"database": "'$MYSQL_ENV_MYSQL_DATABASE'"/' /app/config/mysqlConfig.json
|
sed -i 's/"database": "lbry"/"database": "'$MYSQL_ENV_MYSQL_DATABASE'"/' /app/config/mysqlConfig.json
|
||||||
;;
|
;;
|
||||||
$MYSQL_SERVER_ADDRESS )
|
$MYSQL_SERVER_ADDRESS )
|
||||||
/bin/ash echof warn "This variable is not currently available."
|
echof warn "This variable is not currently available."
|
||||||
;;
|
;;
|
||||||
$SITE_ADDRESS )
|
$SITE_ADDRESS )
|
||||||
/bin/ash echof info "Setting '$SITE_ADDRESS' $1 in /app/config/siteConfig.json"
|
echof info "Setting '$SITE_ADDRESS' $1 in /app/config/siteConfig.json"
|
||||||
sed -i 's/"host": "https://www.example.com"/"host": "https://'$SITE_ADDRESS'"/' /app/config/siteConfig.json
|
sed -i 's/"host": "https://www.example.com"/"host": "https://'$SITE_ADDRESS'"/' /app/config/siteConfig.json
|
||||||
;;
|
;;
|
||||||
$GOOGLE_ANALYTICS_UID )
|
$GOOGLE_ANALYTICS_UID )
|
||||||
/bin/ash echof info "Setting '$GOOGLE_ANALYTICS_UID' $1 in /app/config/siteConfig.json"
|
echof info "Setting '$GOOGLE_ANALYTICS_UID' $1 in /app/config/siteConfig.json"
|
||||||
sed -i 's/"googleId": null/"googleId": '$GOOGLE_ANALYTICS_UID'/' /app/config/siteConfig.json
|
sed -i 's/"googleId": null/"googleId": '$GOOGLE_ANALYTICS_UID'/' /app/config/siteConfig.json
|
||||||
;;
|
;;
|
||||||
$SITE_TITLE )
|
$SITE_TITLE )
|
||||||
/bin/ash echof info "Setting '$SITE_TITLE' $1 in /app/config/siteConfig.json"
|
echof info "Setting '$SITE_TITLE' $1 in /app/config/siteConfig.json"
|
||||||
sed -i 's/"title": "My Site"/"title": "'$SITE_TITLE'"/' /app/config/siteConfig.json
|
sed -i 's/"title": "My Site"/"title": "'$SITE_TITLE'"/' /app/config/siteConfig.json
|
||||||
;;
|
;;
|
||||||
$SITE_DESCRIPTION )
|
$SITE_DESCRIPTION )
|
||||||
/bin/ash echof info "Setting '$SITE_DESCRIPTION' $1 in /app/config/siteConfig.json"
|
echof info "Setting '$SITE_DESCRIPTION' $1 in /app/config/siteConfig.json"
|
||||||
sed -i 's/"description": "A decentralized hosting platform built on LBRY"/"Description": "'$SITE_DESCRIPTION'"/' /app/config/siteConfig.json
|
sed -i 's/"description": "A decentralized hosting platform built on LBRY"/"Description": "'$SITE_DESCRIPTION'"/' /app/config/siteConfig.json
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -55,14 +55,14 @@ function set_conf() {
|
||||||
|
|
||||||
function configure_speech() {
|
function configure_speech() {
|
||||||
# install configuration changes here.
|
# install configuration changes here.
|
||||||
/bin/ash echof info "Installing configuration files into /app/config/."
|
echof info "Installing configuration files into /app/config/."
|
||||||
mkdir -p /app/config/
|
mkdir -p /app/config/
|
||||||
cp /usr/local/src/www.spee.ch/cli/defaults/mysqlConfig.json > /app/config/mysqlConfig.json
|
cp /usr/local/src/www.spee.ch/cli/defaults/mysqlConfig.json > /app/config/mysqlConfig.json
|
||||||
cp /usr/local/src/www.spee.ch/cli/defaults/siteConfig.json > /app/config/siteConfig.json
|
cp /usr/local/src/www.spee.ch/cli/defaults/siteConfig.json > /app/config/siteConfig.json
|
||||||
/bin/ash echof info "Installing any environment variables that have been set."
|
echof info "Installing any environment variables that have been set."
|
||||||
for i in "${envvars[@]}"; do
|
for i in "${envvars[@]}"; do
|
||||||
if [[ -z "$i" ]]; then
|
if [[ -z "$i" ]]; then
|
||||||
/bin/ash echof info "$i was not set, moving on."
|
echof info "$i was not set, moving on."
|
||||||
else
|
else
|
||||||
set_conf $i
|
set_conf $i
|
||||||
fi
|
fi
|
||||||
|
@ -71,12 +71,12 @@ function configure_speech() {
|
||||||
|
|
||||||
function final_permset() {
|
function final_permset() {
|
||||||
## Finally reassert permissions in case there is user added drift.
|
## Finally reassert permissions in case there is user added drift.
|
||||||
rddo /app "/bin/ash test_for_dir" '775 "speech:speech"'
|
rddo /app "test_for_dir" '775 "speech:speech"'
|
||||||
rfdo /app "/bin/ash test_for_file" '665 "speech:speech"'
|
rfdo /app "test_for_file" '665 "speech:speech"'
|
||||||
## Define any permission exceptions here.
|
## Define any permission exceptions here.
|
||||||
# /bin/ash test_for_dir /app/config 775 "speech:speech"
|
# test_for_dir /app/config 775 "speech:speech"
|
||||||
# /bin/ash test_for_file /app/config/siteConfig.json 665 "speech:speech"
|
# test_for_file /app/config/siteConfig.json 665 "speech:speech"
|
||||||
/bin/ash echof info "Copied Spee.ch and set permissions"
|
echof info "Copied Spee.ch and set permissions"
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
|
@ -85,31 +85,31 @@ function final_permset() {
|
||||||
# if Spee.ch is not yet installed, copy it into web root.
|
# if Spee.ch is not yet installed, copy it into web root.
|
||||||
# This could be updated to be part of an upgrade mechanism.
|
# This could be updated to be part of an upgrade mechanism.
|
||||||
if [ "$(ls -A /app)" ]; then
|
if [ "$(ls -A /app)" ]; then
|
||||||
/bin/ash echof warn "/app is not Empty. It contains:" 1>&2
|
echof warn "/app is not Empty. It contains:" 1>&2
|
||||||
ls -A 1>&2
|
ls -A 1>&2
|
||||||
## If siteConfig.json isn't installed add it and configure or ignore and proceed.
|
## If siteConfig.json isn't installed add it and configure or ignore and proceed.
|
||||||
if [ ! -e '/app/config/siteConfig.json' ]; then
|
if [ ! -e '/app/config/siteConfig.json' ]; then
|
||||||
/bin/ash echof warn "Spee.ch doesn't appear to have a configuration."
|
echof warn "Spee.ch doesn't appear to have a configuration."
|
||||||
/bin/ash echof blank "Don't worry we can install it for you."
|
echof blank "Don't worry we can install it for you."
|
||||||
configure_speech
|
configure_speech
|
||||||
else
|
else
|
||||||
## If the file exists skip configuration and proceed.
|
## If the file exists skip configuration and proceed.
|
||||||
/bin/ash echof info "Spee.ch config already installed skipping configuration step."
|
echof info "Spee.ch config already installed skipping configuration step."
|
||||||
final_permset
|
final_permset
|
||||||
fi
|
fi
|
||||||
## Install all other files after installing siteConfig.json
|
## Install all other files after installing siteConfig.json
|
||||||
/bin/ash echof info "Making an attempt to nicely merge files using:"
|
echof info "Making an attempt to nicely merge files using:"
|
||||||
/bin/ash echof run "mv -fnu /usr/local/src/www.spee.ch/* /app/"
|
echof run "mv -fnu /usr/local/src/www.spee.ch/* /app/"
|
||||||
mv -fnu /usr/local/src/www.spee.ch/* /app/
|
mv -fnu /usr/local/src/www.spee.ch/* /app/
|
||||||
final_permset
|
final_permset
|
||||||
else
|
else
|
||||||
/bin/ash echof info "Speech wasn't installed, installing fresh copy now."
|
echof info "Speech wasn't installed, installing fresh copy now."
|
||||||
configure_speech
|
configure_speech
|
||||||
/bin/ash echof run "mv /usr/local/src/www.spee.ch/* /app/"
|
echof run "mv /usr/local/src/www.spee.ch/* /app/"
|
||||||
mv /usr/local/src/www.spee.ch/* /app/
|
mv /usr/local/src/www.spee.ch/* /app/
|
||||||
final_permset
|
final_permset
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Superfluous permissions assertion maybe axe this later.
|
## Superfluous permissions assertion maybe axe this later.
|
||||||
/bin/ash echof run '/bin/ash test_for_dir /app/config/siteConfig.json 775 "speech:speech"'
|
echof run 'test_for_dir /app/config/siteConfig.json 775 "speech:speech"'
|
||||||
/bin/ash test_for_file /app/config/siteConfig.json 775 "speech:speech"
|
test_for_file /app/config/siteConfig.json 775 "speech:speech"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
curl --fail http://localhost:3000/ || exit 1
|
curl --fail http://localhost:3000/ || exit 1
|
||||||
|
|
Loading…
Reference in a new issue