This repository has been archived on 2021-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
docker-peertube/support/docker/production/docker-entrypoint.sh

65 lines
2.1 KiB
Bash
Raw Normal View History

2019-11-16 10:49:03 +01:00
#!/bin/bash
## author : Dryusdan
## date : 16/11/2019
## description : Start Peertube
## usage : ./docker-entrypoint.sh
## Bash strict mode ####################################
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
## Bash color ##########################################
# Set colors
RED='\033[0;31m'
GREEN='\033[00;32m'
YELLOW='\033[00;33m'
BLUE='\033[00;34m'
PURPLE='\033[00;35m'
CYAN='\033[00;36m'
LIGHTGRAY='\033[00;37m'
LRED='\033[01;31m'
LGREEN='\033[01;32m'
LYELLOW='\033[01;33m'
LBLUE='\033[01;34m'
LPURPLE='\033[01;35m'
LCYAN='\033[01;36m'
WHITE='\033[01;37m'
NC='\033[0m' # No Color
## Logs ################################################
readonly SCRIPTNAME="$(basename "$0")"
info() { echo -e "${LBLUE}[INFO] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; }
warning() { echo -e "${YELLOW}[WARNING] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; }
error() { echo -e "${LRED}[ERROR] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; }
fatal() { echo -e "${RED}[FATAL] $* ${NC}" | logger --tag "${SCRIPTNAME}" --stderr ; exit 1 ; }
########################################################
usermod -u ${GID} peertube
groupmod -g ${UID} peertube
info "Populate config directory"
if [ -z "$(ls -A /config)" ]; then
cp /app/support/docker/production/config/* /config
fi
# Always copy default and custom env configuration file, in cases where new keys were added
cp /app/config/default.yaml /config
cp /app/support/docker/production/config/custom-environment-variables.yaml /config
find /config ! -user peertube -exec chown peertube:peertube {} \;
# first arg is `-f` or `--some-option`
# or first arg is `something.conf`
if [ "${1#-}" != "${1}" ] || [ "${1%.conf}" != "${1}" ]; then
set -- npm "${@}"
fi
if [ ${FORCE_CHOWN} ]; then
warning "Force chown is set to true. This may take a time"
find /data ! -user peertube -exec chown peertube:peertube {} \;
fi
info "PeerTube Launch"
exec su - peertube -c "cd /app && npm start"