Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
proc
/
thread-self
/
root
/
proc
/
212
/
root
/
proc
/
thread-self
/
root
/
lib
/
//proc/thread-self/root/proc/212/root/proc/thread-self/root/lib/start-lib.sh
#!/bin/bash -e ## CREATES THE ENVIRONEMENT export LANG=C export LC_ALL=C export PAAS_USER='hosting-user' export APP_USER='hosting-app0' export SYS_USER='hosting-admin' export DB_USER='hosting-db' export PHP_USER=${PAAS_USER} export GITWEB_USER=${PAAS_USER} export CUSTOMER_DIR='/srv/data' export HOME="/home/${PAAS_USER}" export LOCAL_DIR='/srv/run' export PREFIX='/' # for npm function do_as() { # TODO: Improve this by using SMACK local user="$1" shift /sbin/capsh --secbits=0x2f \ --user="$user" --caps="all=" \ -- -c 'exec "$0" "$@"' "$@" # Last line protects arguments separation } # Parses the arguments common to all init scripts, and sets # the corresponding variables, but only applies them # on start-lib.sh . It is the responsability of the calling # script to set global effects (like changing the gateway). # The reason for that is to respect modularity. function parse_arguments() { while [ $# -gt 0 ]; do case "$1" in '--engine') if [[ -z "$2" ]]; then echo "Invalid engine ($1 $2)" exit 1 fi export WWW_ENGINE="$2" shift ;; '--db') if [[ -z "$2" ]]; then echo "Invalid db ($1 $2)" exit 1 fi export DB_ENGINE="$2" shift ;; '--no-db') export DB_ENGINE="" ;; '--debug') export NO_TTY_REDIRECTIONS=true ;; '--rescue-grant-tables') export RESCUE_GRANT_TABLES=true ;; '--shell-start') export SHELL_START=true ;; '--paas') if [[ -z "$2" ]]; then echo "Invalid PAAS type ($1 $2)" exit 1 fi export PAAS="$2" shift ;; '--') shift if [ $# -gt 1 -a "$1" = "deploy" ]; then export VHOST=$(extract_vhost "$2") export TREEISH="$3" fi break ;; esac shift done } # Writes on its standard output the amount of available memory # Requires /cgroup to be mounted function get_cgroup_max_memory_mb() { # Parses the path to isolate the cgroup name local proc read proc < /proc/self/cgroup # Only keeps the last column local cgroup_name=${proc##*:} local mem_bytes read mem_bytes < /cgroup/$cgroup_name/memory.limit_in_bytes echo $(( $mem_bytes / 1024 / 1024 )) } function logrotate_console_file() { local data_path="" if [ -z "$NO_MOUNT" ]; then data_path=${PAAS-lamp0} fi local console_file="${CUSTOMER_DIR}/${data_path}/var/log/boot/console.log" local state_file=/dev/null local logrotate_conf="/srv/admin/${data_path}/configs/logrotate/console.conf" local logrotate_user=$SYS_USER if [ "$DISTRIB" = "jessie" ]; then console_file="${CUSTOMER_DIR}/var/log/boot/console.log" state_file="${LOCAL_DIR}/logrotate.state" logrotate_conf="/srv/admin/configs/logrotate/console.conf" logrotate_user=nobody do_as "${SYS_USER}" find "${CUSTOMER_DIR}/var/log/boot/" -user "${SYS_USER}" -type f -exec chmod o+w "{}" \; fi # this is error prone due to bad usage of delegations by the kernel # it may fail if the console log file has been opened by eg. apache and then instance is restarted set +e chmod 646 "$console_file" set -e do_as "$logrotate_user" /usr/sbin/logrotate -f -s "$state_file" \ "$logrotate_conf" > /dev/null return 0 } function go_console() { if [[ -z "$NO_TTY_REDIRECTIONS" ]]; then logrotate_console_file exec < /dev/console exec &> /dev/console fi } function start_user_shell_on_tty() { local user="$1" local tty="$2" if [[ -z "$NO_TTY_REDIRECTIONS" ]]; then echo "Starting a shell for $user on $tty" /bin/start-shell /bin/restart-shell $user < "/dev/$tty" >& "/dev/$tty" fi } function check_gitweb_needed() { shopt -s nullglob declare -a repos=(/srv/data/vcs/git/*.git) shopt -u nullglob [ ${#repos[*]} -eq 0 ] && return 1 || return 0 } function setup_mount_points() { readonly tmp_mnt='/mnt' readonly tmpfs_size=32768 readonly data_mount="/srv/data/lamp0" readonly admin_mount="/srv/admin/$PAAS" mount -n -t tmpfs -o noexec,nosuid,nodev,size="$tmpfs_size" tmpfs /dev/shm mount -n -t tmpfs -o noexec,nosuid,nodev,size="$tmpfs_size" /dev/mem "$tmp_mnt" install -d -m 1777 "$tmp_mnt/run" install -d "$tmp_mnt/data" "$tmp_mnt/admin" mount -n --bind "$data_mount" "$tmp_mnt/data" mount -n -o ro --bind "$admin_mount" "$tmp_mnt/admin" mount -n --move "$tmp_mnt" /srv mount -n -o bind "${CUSTOMER_DIR}/tmp" /tmp mount -n -t tmpfs -o nosuid,nodev,mode=1755,size="$tmpfs_size" /dev/mem /home mkdir $HOME mount -n -o bind "${CUSTOMER_DIR}/home" $HOME mount -n -t proc none /proc || true } function initialize_urandom() { stat /dev/urandom > /dev/null } function extract_vhost() { local reponame="$1" reponame="${reponame#\'}" reponame="${reponame%\'}" echo "${reponame%.git}" } parse_json() { JSON_FILE=$1 if [ -f ${JSON_FILE} ]; then export WWW_ENGINE=$(jq -r .language.name ${JSON_FILE}) export WWW_VERSION=$(jq -r .language.version ${JSON_FILE}) export DB_ENGINE=$(jq -r .database.name ${JSON_FILE}) export DB_VERSION=$(jq -r .database.version ${JSON_FILE}) DB_PATH=$DB_ENGINE WWW_PATH=$WWW_ENGINE case "${WWW_ENGINE}" in python) PYTHON_VERSION=$(/srv/admin/scripts/python/python-version.py || true) if [ ! -z ${PYTHON_VERSION} ]; then export WWW_VERSION=${PYTHON_VERSION} fi ;; esac case "${DB_ENGINE}" in pgsql) DB_PATH="postgresql" ;; esac export WWW_VERSION=$(echo $WWW_VERSION | sed 's/[^.0-9]//g') export DB_VERSION=$(echo $DB_VERSION | sed 's/[^.0-9]//g') export PATH="$PATH:/opt/${WWW_PATH}-${WWW_VERSION}/bin:/opt/${WWW_PATH}-${WWW_VERSION}/sbin:/opt/${WWW_PATH}-${WWW_VERSION}/usr/bin:/opt/${WWW_PATH}-${WWW_VERSION}/usr/sbin" export PATH="$PATH:/opt/${DB_PATH}-${DB_VERSION}/bin:/opt/${DB_PATH}-${DB_VERSION}/sbin:/opt/${DB_PATH}-${DB_VERSION}/usr/bin:/opt/${DB_PATH}-${DB_VERSION}/usr/sbin" export PATH="$PATH:/opt/sqlite-3/bin" case "${DB_ENGINE}" in mysql) lib_path="/opt/mysql-${DB_VERSION}/lib/x86_64-linux-gnu" ;; pgsql) lib_path="/opt/postgresql-${DB_VERSION}/lib" ;; esac if [ -n "${lib_path-}" ]; then if [ -n "${LD_LIBRARY_PATH-}" ]; then export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${lib_path}" else export LD_LIBRARY_PATH="${lib_path}" fi fi fi }