Skip to content

Commit

Permalink
Merge pull request #47 from nuxsmin/3.2
Browse files Browse the repository at this point in the history
Version 3.2
  • Loading branch information
nuxsmin authored Dec 20, 2020
2 parents 806f26b + a5794cc commit 7dfc7bc
Show file tree
Hide file tree
Showing 34 changed files with 457 additions and 1,247 deletions.
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
VERSION=3.2.0
BUILD_NUMBER=20122001

build_vendor:
cd build \
&& ./build-vendor.sh \
&& cd ..

build_version:
cd common \
&& VERSION=${VERSION} \
BUILD_NUMBER=${BUILD_NUMBER} \
./build.sh env \
&& cd ..

build_docker:
cd common \
&& VERSION=${VERSION} \
BUILD_NUMBER=${BUILD_NUMBER} \
./build.sh docker \
&& cd ..
13 changes: 9 additions & 4 deletions common/build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#!/bin/bash

set -euo pipefail

BUILDS=`find ../ -type d -name sysPass-*`
BRANCH="master"
VERSION="3.1.2"
BUILD_NUMBER="19030701"
BRANCH="${VERSION:=master}"

if [ -z "${VERSION}" ] || [ -z ${BUILD_NUMBER} ]; then
echo "ERROR: VERSION and BUILD_NUMBER must be set"
exit 1
fi

build_env() {
for BUILD in ${BUILDS}; do
TAG=`echo ${BUILD} | cut -d'-' -f2`

echo "Building env for ${TAG} (${BUILD})"

cp -af entrypoint.sh syspass.conf ${BUILD}/
cp -af entrypoint.sh syspass.conf common_fn.sh ${BUILD}/

sed -i 's/SYSPASS_BRANCH="[a-z0-9\.]\+"/SYSPASS_BRANCH="'${BRANCH}'"/i;
s/version=[a-z0-9\.\-]\+/version='${VERSION}'/i;
Expand Down
102 changes: 47 additions & 55 deletions sysPass-php7.2/entrypoint.sh → common/common_fn.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,20 +1,55 @@
#!/bin/bash
: ${XDEBUG_REMOTE_HOST:="172.17.0.1"}
: ${XDEBUG_IDE_KEY:="ide"}
: ${SYSPASS_DEV:=0}
: ${PHP_XDEBUG_FILE:="/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"}
: ${SYSPASS_LOCALES:="es_ES en_US en_GB de_DE ca_ES fr_FR ru_RU pl_PL nl_NL pt_BR da_DK it_IT fo_FO ja_JP"}
: ${COMPOSER_EXTENSIONS:=}
: ${DEBUG:=0}

if [ ${DEBUG} -eq 1 ]; then
set -x
fi

COMPOSER_OPTIONS="--working-dir ${SYSPASS_DIR} --classmap-authoritative"
GOSU="gosu ${SYSPASS_UID}"

COLOR_NC='\033[0m'
COLOR_YELLOW='\033[0;33m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'

XDEBUG_REMOTE_HOST=${XDEBUG_REMOTE_HOST:-"172.17.0.1"}
XDEBUG_IDE_KEY=${XDEBUG_IDE_KEY:-"ide"}
if [ ${SYSPASS_DEV} -eq 1 ]; then
COMPOSER_OPTIONS="--working-dir ${SYSPASS_DIR} --optimize-autoloader --dev"
fi

COMPOSER_OPTIONS="--working-dir ${SYSPASS_DIR} --classmap-authoritative"
setup_apache () {
if [ ${SYSPASS_DEV} -eq 0 ]; then
return 0
fi

GOSU="gosu ${SYSPASS_UID}"
echo -e "${COLOR_YELLOW}setup_apache: Setting up xdebug variables${COLOR_NC}"

if [ -e /usr/local/sbin/init-functions ]; then
. /usr/local/sbin/init-functions
fi
sed -i 's/__XDEBUG_REMOTE_HOST__/'"$XDEBUG_REMOTE_HOST"'/;
s/__XDEBUG_IDE_KEY__/'"$XDEBUG_IDE_KEY"'/' \
${PHP_XDEBUG_FILE}
}

run_apache () {
: ${PHP_INI_DIR:=}

if [ -z "${PHP_INI_DIR}" ]; then
echo -e "${COLOR_YELLOW}run_apache: Starting Apache${COLOR_NC}"

# Apache gets grumpy about PID files pre-existing
rm -f ${APACHE_PID_FILE}

exec /usr/sbin/apache2ctl -DFOREGROUND
else
echo -e "${COLOR_YELLOW}run_apache: Starting Apache (PHP)${COLOR_NC}"

apache2-foreground
fi
}

setup_app () {
if [ -e "${SYSPASS_DIR}/index.php" ]; then
Expand Down Expand Up @@ -45,19 +80,10 @@ setup_locales() {
echo -e "${COLOR_YELLOW}setup_locales: Setting up locales${COLOR_NC}"

echo -e "\n### sysPass locales" >> $LOCALE_GEN
echo "es_ES.UTF-8 UTF-8" >> $LOCALE_GEN
echo "en_US.UTF-8 UTF-8" >> $LOCALE_GEN
echo "en_GB.UTF-8 UTF-8" >> $LOCALE_GEN
echo "de_DE.UTF-8 UTF-8" >> $LOCALE_GEN
echo "ca_ES.UTF-8 UTF-8" >> $LOCALE_GEN
echo "fr_FR.UTF-8 UTF-8" >> $LOCALE_GEN
echo "ru_RU.UTF-8 UTF-8" >> $LOCALE_GEN
echo "pl_PL.UTF-8 UTF-8" >> $LOCALE_GEN
echo "nl_NL.UTF-8 UTF-8" >> $LOCALE_GEN
echo "pt_BR.UTF-8 UTF-8" >> $LOCALE_GEN
echo "da.UTF-8 UTF-8" >> $LOCALE_GEN
echo "it_IT.UTF-8 UTF-8" >> $LOCALE_GEN
echo "fo.UTF-8 UTF-8" >> $LOCALE_GEN

for LOCALE in ${SYSPASS_LOCALES}; do
echo "${LOCALE}.UTF-8 UTF-8" >> $LOCALE_GEN
done

echo 'LANG="en_US.UTF-8"' > /etc/default/locale

Expand Down Expand Up @@ -94,37 +120,3 @@ setup_composer_extensions () {
run_composer require ${COMPOSER_EXTENSIONS} --update-no-dev
fi
}

echo -e "${COLOR_YELLOW}entrypoint: Starting with UID : ${SYSPASS_UID}${COLOR_NC}"
id ${SYSPASS_UID} > /dev/null 2>&1 || useradd --shell /bin/bash -u ${SYSPASS_UID} -o -c "" -m user
export HOME=${SYSPASS_DIR}

setup_app

case "$1" in
"apache")
setup_composer_extensions
setup_locales
setup_apache

SELF_IP_ADDRESS=$(grep $HOSTNAME /etc/hosts | cut -f1)

echo -e "${COLOR_GREEN}######"
echo -e "sysPass environment installed and configured. Please point your browser to https://${SELF_IP_ADDRESS} to start the installation"
echo -e "######${COLOR_NC}"
echo -e "${COLOR_YELLOW}entrypoint: Starting Apache${COLOR_NC}"

run_apache
;;
"update")
run_composer update
;;
"composer")
shift
run_composer "$@"
;;
*)
echo -e "${COLOR_YELLOW}entrypoint: Starting $@${COLOR_NC}"
exec ${GOSU} "$@"
;;
esac
113 changes: 19 additions & 94 deletions common/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,102 +1,16 @@
#!/bin/bash
#!/usr/bin/env bash

COLOR_NC='\033[0m'
COLOR_YELLOW='\033[0;33m'
COLOR_RED='\033[0;31m'
COLOR_GREEN='\033[0;32m'
set -euo pipefail

XDEBUG_REMOTE_HOST=${XDEBUG_REMOTE_HOST:-"172.17.0.1"}
XDEBUG_IDE_KEY=${XDEBUG_IDE_KEY:-"ide"}
COMMON_FN="common_fn.sh"

COMPOSER_OPTIONS="--working-dir ${SYSPASS_DIR} --classmap-authoritative"
source ${COMMON_FN}

GOSU="gosu ${SYSPASS_UID}"

if [ -e /usr/local/sbin/init-functions ]; then
. /usr/local/sbin/init-functions
fi

setup_app () {
if [ -e "${SYSPASS_DIR}/index.php" ]; then
echo -e "${COLOR_YELLOW}setup_app: Setting up permissions${COLOR_NC}"

RW_DIRS="${SYSPASS_DIR}/app/config \
${SYSPASS_DIR}/app/backup \
${SYSPASS_DIR}/app/cache \
${SYSPASS_DIR}/app/resources \
${SYSPASS_DIR}/app/temp"

chown ${APACHE_RUN_USER}:${SYSPASS_UID} -R ${RW_DIRS}

chmod 750 ${RW_DIRS}

chown ${SYSPASS_UID}:${SYSPASS_UID} -R \
${SYSPASS_DIR}/app/modules/*/plugins \
${SYSPASS_DIR}/composer.json \
${SYSPASS_DIR}/composer.lock \
${SYSPASS_DIR}/vendor
fi
}

setup_locales() {
if [ ! -e ".setup" ]; then
LOCALE_GEN="/etc/locale.gen"

echo -e "${COLOR_YELLOW}setup_locales: Setting up locales${COLOR_NC}"

echo -e "\n### sysPass locales" >> $LOCALE_GEN
echo "es_ES.UTF-8 UTF-8" >> $LOCALE_GEN
echo "en_US.UTF-8 UTF-8" >> $LOCALE_GEN
echo "en_GB.UTF-8 UTF-8" >> $LOCALE_GEN
echo "de_DE.UTF-8 UTF-8" >> $LOCALE_GEN
echo "ca_ES.UTF-8 UTF-8" >> $LOCALE_GEN
echo "fr_FR.UTF-8 UTF-8" >> $LOCALE_GEN
echo "ru_RU.UTF-8 UTF-8" >> $LOCALE_GEN
echo "pl_PL.UTF-8 UTF-8" >> $LOCALE_GEN
echo "nl_NL.UTF-8 UTF-8" >> $LOCALE_GEN
echo "pt_BR.UTF-8 UTF-8" >> $LOCALE_GEN
echo "da.UTF-8 UTF-8" >> $LOCALE_GEN
echo "it_IT.UTF-8 UTF-8" >> $LOCALE_GEN
echo "fo.UTF-8 UTF-8" >> $LOCALE_GEN

echo 'LANG="en_US.UTF-8"' > /etc/default/locale

dpkg-reconfigure --frontend=noninteractive locales

update-locale LANG=en_US.UTF-8

export LANG=en_US.UTF-8

echo "1" > .setup
else
echo -e "${COLOR_YELLOW}setup_locales: Locales already set up${COLOR_NC}"
fi
}

run_composer () {
pushd ${SYSPASS_DIR}

if [ -e "./composer.lock" -a -e "composer.json" ]; then
echo -e "${COLOR_YELLOW}run_composer: Running composer${COLOR_NC}"

${GOSU} composer "$@" ${COMPOSER_OPTIONS}
else
echo -e "${COLOR_RED}run_composer: Error, composer not set up${COLOR_NC}"
fi

popd
}

setup_composer_extensions () {
if [ -n "${COMPOSER_EXTENSIONS}" ]; then
echo -e "${COLOR_YELLOW}setup_composer_extensions: ${COMPOSER_EXTENSIONS}${COLOR_NC}"
echo -e "${COLOR_YELLOW}entrypoint: Starting with UID : ${SYSPASS_UID}${COLOR_NC}"

run_composer require ${COMPOSER_EXTENSIONS} --update-no-dev
fi
}
id ${SYSPASS_UID} > /dev/null 2>&1 \
|| useradd --shell /bin/bash -u ${SYSPASS_UID} -o -c "" -m user

echo -e "${COLOR_YELLOW}entrypoint: Starting with UID : ${SYSPASS_UID}${COLOR_NC}"
id ${SYSPASS_UID} > /dev/null 2>&1 || useradd --shell /bin/bash -u ${SYSPASS_UID} -o -c "" -m user
export HOME=${SYSPASS_DIR}

setup_app
Expand All @@ -110,17 +24,28 @@ case "$1" in
SELF_IP_ADDRESS=$(grep $HOSTNAME /etc/hosts | cut -f1)

echo -e "${COLOR_GREEN}######"
echo -e "sysPass environment installed and configured. Please point your browser to https://${SELF_IP_ADDRESS} to start the installation"
echo -e "sysPass environment installed and configured. Please point your browser to https://${SELF_IP_ADDRESS} to start the installation."
echo -e "######${COLOR_NC}"
echo -e "${COLOR_YELLOW}entrypoint: Starting Apache${COLOR_NC}"

run_apache
;;
"update")
echo -e "${COLOR_YELLOW}######"
echo -e "Please, only run this command for debuging purposes."
echo -e "In order to update the dependencies, please, download and updated image"
echo -e "######${COLOR_NC}"

run_composer update
;;
"composer")
shift

echo -e "${COLOR_YELLOW}######"
echo -e "Please, only run this command for debuging purposes."
echo -e "In order to update the dependencies, please, download and updated image"
echo -e "######${COLOR_NC}"

run_composer "$@"
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '2'
services:
app:
container_name: syspass-app
image: syspass/syspass:3.1.2
image: syspass/syspass:3.2.0
restart: always
ports:
- "80"
Expand Down
Loading

0 comments on commit 7dfc7bc

Please sign in to comment.