From 8031a713227c8d3d9a605ba87fb3c3fb1e631c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:17:48 +0200 Subject: [PATCH 01/11] Update init.sh --- install/OS_specific/Docker/init.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/install/OS_specific/Docker/init.sh b/install/OS_specific/Docker/init.sh index 72aca77f2f..a34be070f8 100644 --- a/install/OS_specific/Docker/init.sh +++ b/install/OS_specific/Docker/init.sh @@ -22,8 +22,6 @@ docker_stop(){ service mariadb stop echo "${VERT}Stopping ATD gracefully${NORMAL}" service atd stop - echo "${VERT}Stopping fail2ban gracefully${NORMAL}" - service fail2ban stop echo "${ROUGE}Requesting stop on init.sh${NORMAL}" touch ${FILE_STOP} exit 0 @@ -61,9 +59,6 @@ Start mariadb service sed -i "s/#PORT#/${DB_PORT:-3306}/g" ${WEBSERVER_HOME}/core/config/common.config.php sed -i "s/#HOST#/${DB_HOST:-localhost}/g" ${WEBSERVER_HOME}/core/config/common.config.php - # remove default fail2ban, contains useless sshd check - rm /etc/fail2ban/jail.d/defaults-debian.conf - echo "************************ start JEEDOM PHP script installation ************************" @@ -108,11 +103,6 @@ chmod 755 -R ${WEBSERVER_HOME} echo 'Start apache2' service apache2 start service apache2 status - -echo 'Start fail2ban' -service fail2ban start -service fail2ban status - echo 'Start CRON daemon' cron From 457ac0c0e6c915c9304c42c1c4a6b3613568e6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:04:25 +0200 Subject: [PATCH 02/11] Update update.php --- install/update.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install/update.php b/install/update.php index 7b6c5ff6d1..a2268b68cc 100644 --- a/install/update.php +++ b/install/update.php @@ -208,6 +208,12 @@ if(version_compare(PHP_VERSION, '8.0.0') >= 0 && file_exists($cibDir . '/vendor')){ shell_exec('rm -rf ' . $cibDir . '/vendor'); } + + echo "Update modification date of unzip file..."; + shell_exec('find '.$cibDir.'/ -exec touch {} +'); + echo "OK\n"; + echo "[PROGRESS][47]\n"; + echo "Moving files..."; $update_begin = true; $file_copy = array(); From 392b4b94c6c38960e6e8b45943235fa8a2880837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:04:46 +0200 Subject: [PATCH 03/11] Update update.php --- install/update.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install/update.php b/install/update.php index 7b6c5ff6d1..a2268b68cc 100644 --- a/install/update.php +++ b/install/update.php @@ -208,6 +208,12 @@ if(version_compare(PHP_VERSION, '8.0.0') >= 0 && file_exists($cibDir . '/vendor')){ shell_exec('rm -rf ' . $cibDir . '/vendor'); } + + echo "Update modification date of unzip file..."; + shell_exec('find '.$cibDir.'/ -exec touch {} +'); + echo "OK\n"; + echo "[PROGRESS][47]\n"; + echo "Moving files..."; $update_begin = true; $file_copy = array(); From 9fd8dcad216c8265baec20a9416ea34d78a62091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:39:26 +0200 Subject: [PATCH 04/11] bugfix --- core/class/event.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/class/event.class.php b/core/class/event.class.php index d8ac7eb4e1..533b82ad16 100644 --- a/core/class/event.class.php +++ b/core/class/event.class.php @@ -126,7 +126,7 @@ private static function filterEvent($_events = array(), $_filter = null) { } $filters = ($_filter !== null) ? cache::byKey($_filter . '::event')->getValue(array()) : array(); $return = array(); - foreach (_events as $event) { + foreach ($_events as $event) { if ($_filter !== null && isset($_filter::$_listenEvents) && !in_array($event->getName(), $_filter::$_listenEvents)) { continue; } From 9f916da35675cf6a48f7575c5427137549338004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Fri, 16 Aug 2024 09:03:41 +0200 Subject: [PATCH 05/11] bugfix --- core/class/cache.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/class/cache.class.php b/core/class/cache.class.php index 2ea25458bc..5a7d9398be 100644 --- a/core/class/cache.class.php +++ b/core/class/cache.class.php @@ -368,7 +368,7 @@ public function getTimestamp(){ } public function setTimestamp($_timestamp){ - $this->datetime = $timestamp; + $this->datetime = $_timestamp; return $this; } } From 514b00e94e34131d52d8e036adb5eb621d34d47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:36:57 +0200 Subject: [PATCH 06/11] bugfix --- core/repo/market.display.repo.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/repo/market.display.repo.php b/core/repo/market.display.repo.php index 35b8fbd782..5d88caed34 100644 --- a/core/repo/market.display.repo.php +++ b/core/repo/market.display.repo.php @@ -90,10 +90,9 @@ } else { if (config::byKey('market::apikey') != '' || (config::byKey('market::username') != '' && config::byKey('market::password') != '')) { $purchase_info = repo_market::getPurchaseInfo(); - if (isset($purchase_info['user_id']) && is_numeric($purchase_info['user_id'])) { - ?> + if (isset($purchase_info['user_id']) && is_numeric($purchase_info['user_id'])) { ?> /index.php?v=d&p=profils' target="_blank"> {{Code promo}} - getCertification() !== 'Premium') { echo ' {{Acheter}}'; } else { @@ -117,7 +116,7 @@ echo '{{Nous Contacter}}'; } else { if ($market->getCost() > 0) { - if (isset($purchase_info['user_id']) && is_numeric($purchase_info['user_id'])) { + if ($market->getPurchase() == 1 && isset($purchase_info['user_id']) && is_numeric($purchase_info['user_id'])) { echo '{{Plugin deja acheté et/ou inclus dans votre service Pack}}'; }else{ if ($market->getCost() != $market->getRealCost()) { From 869ed5654c9985a628b6c04c1c962910c231df11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:14:22 +0200 Subject: [PATCH 07/11] improve install --- install/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/install.sh b/install/install.sh index 8dfd9671ba..8adc392921 100644 --- a/install/install.sh +++ b/install/install.sh @@ -167,6 +167,7 @@ step_6_jeedom_download() { fi cp -R /root/core-*/* ${WEBSERVER_HOME} cp -R /root/core-*/.[^.]* ${WEBSERVER_HOME} + find ${WEBSERVER_HOME}/ -exec touch {} + rm -rf /root/core-* > /dev/null 2>&1 rm /tmp/jeedom.zip echo "${GREEN}Step 6 - download Jeedom done${NORMAL}" From 249799f65665ce90daead1662f7a5bb3747315bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Fri, 6 Sep 2024 14:45:12 +0200 Subject: [PATCH 08/11] Update install.sh --- install/install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install/install.sh b/install/install.sh index 8adc392921..be938b06be 100644 --- a/install/install.sh +++ b/install/install.sh @@ -167,6 +167,7 @@ step_6_jeedom_download() { fi cp -R /root/core-*/* ${WEBSERVER_HOME} cp -R /root/core-*/.[^.]* ${WEBSERVER_HOME} + cp -R /root/core-*/.htaccess ${WEBSERVER_HOME}/htaccess find ${WEBSERVER_HOME}/ -exec touch {} + rm -rf /root/core-* > /dev/null 2>&1 rm /tmp/jeedom.zip @@ -346,6 +347,11 @@ step_10_jeedom_installation() { exit 1 fi fi + + if [ ! -f ${WEBSERVER_HOME}/.htaccess ];then + cp -R ${WEBSERVER_HOME}/htaccess ${WEBSERVER_HOME}/.htaccess + fi + rm ${WEBSERVER_HOME}/.htaccess echo "${GREEN}Step 10 - Jeedom install done${NORMAL}" } From 27f1754f86cd95269da81d9170cc94c8d6002230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Sat, 7 Sep 2024 11:46:07 +0200 Subject: [PATCH 09/11] fix docker --- install/OS_specific/Docker/init.sh | 174 +++++++++++++++++------------ 1 file changed, 105 insertions(+), 69 deletions(-) diff --git a/install/OS_specific/Docker/init.sh b/install/OS_specific/Docker/init.sh index a34be070f8..ca57203726 100644 --- a/install/OS_specific/Docker/init.sh +++ b/install/OS_specific/Docker/init.sh @@ -1,5 +1,4 @@ #!/bin/bash - VERT="\\033[1;32m" NORMAL="\\033[0;39m" ROUGE="\\033[1;31m" @@ -9,88 +8,130 @@ BLANC="\\033[0;02m" BLANCLAIR="\\033[1;08m" JAUNE="\\033[1;33m" CYAN="\\033[1;36m" - -FILE_STOP="/root/stop_requested" - -docker_stop(){ - echo "${JAUNE}Stopping Jeedom container${NORMAL}" - echo "${VERT}Killing CRON${NORMAL}" - killall cron - echo "${VERT}Stopping Apache gracefully${NORMAL}" - service apache2 stop - echo "${VERT}Stopping Database gracefully${NORMAL}" - service mariadb stop - echo "${VERT}Stopping ATD gracefully${NORMAL}" - service atd stop - echo "${ROUGE}Requesting stop on init.sh${NORMAL}" - touch ${FILE_STOP} - exit 0 + +service_mariadb(){ + service mysql $1 + if [ $? -ne 0 ]; then + service mariadb $1 + if [ $? -ne 0 ]; then + echo "${ROUGE}Cannot start mariadb - Cancelling${NORMAL}" + return 1 + fi + fi + return 0 } -# flag to fail fast on errors -set -e - -# $WEBSERVER_HOME and $VERSION env variables comes from Dockerfile - -if [[ -f ${WEBSERVER_HOME}/initialisation ]]; then - echo "************************ -Start JEEDOM initialisation ! -************************" - JEEDOM_INSTALL=0 - - echo "************************ -Start mariadb service -************************" +docker_stop() { + echo "${JAUNE}Stopping Jeedom container${NORMAL}" + echo "${VERT}Killing CRON${NORMAL}" + killall cron + echo "${VERT}Stopping Apache gracefully${NORMAL}" + service apache2 stop + if [[ 1 -eq ${ISMARIABDBINSTALLED} ]]; then + echo "${VERT}Stopping Database gracefully${NORMAL}" + service mariadb stop + fi + echo "${VERT}Stopping ATD gracefully${NORMAL}" + service atd stop + echo "${ROUGE}Requesting stop on init.sh${NORMAL}" + touch ${FILE_STOP} + exit 0 +} - service mariadb start - service mariadb status +setTimeZone() { + [[ ${TZ} == $( + Listen ${APACHE_HTTPS_PORT:-443} + + + + Listen ${APACHE_HTTPS_PORT:-443} + " >/etc/apache2/ports.conf + sed -i -E "s/\/VirtualHost \*:${APACHE_HTTP_PORT}/" /etc/apache2/sites-available/000-default.conf + sed -i -E "s/\/VirtualHost \*:${APACHE_HTTPS_PORT}/" /etc/apache2/sites-available/default-ssl.conf + fi +} - echo "************************ -start JEEDOM PHP script installation -************************" +echo 'Start init' - php ${WEBSERVER_HOME}/install/install.php mode=force +# $WEBSERVER_HOME and $VERSION env variables comes from Dockerfile - # remove the flag file after the first successfull installation - rm ${WEBSERVER_HOME}/initialisation +if [ -f ${WEBSERVER_HOME}/core/config/common.config.php ]; then + echo 'Jeedom is already install' + JEEDOM_INSTALL=1 +else + echo 'Start jeedom installation' + JEEDOM_INSTALL=0 + rm -rf /root/install.sh + wget https://raw.githubusercontent.com/jeedom/core/${VERSION}/install/install.sh -O /root/install.sh + chmod +x /root/install.sh + /root/install.sh -s 6 -v ${VERSION} -w ${WEBSERVER_HOME} + if [ $(which mysqld | wc -l) -ne 0 ]; then + chown -R mysql:mysql /var/lib/mysql + mysql_install_db --user=mysql --basedir=/usr/ --ldata=/var/lib/mysql/ + service_mariadb restart + MYSQL_JEEDOM_PASSWD=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 15) + echo "DROP USER 'jeedom'@'localhost';" | mysql > /dev/null 2>&1 + echo "CREATE USER 'jeedom'@'localhost' IDENTIFIED BY '${MYSQL_JEEDOM_PASSWD}';" | mysql + echo "DROP DATABASE IF EXISTS jeedom;" | mysql + echo "CREATE DATABASE jeedom;" | mysql + echo "GRANT ALL PRIVILEGES ON jeedom.* TO 'jeedom'@'localhost';" | mysql + cp ${WEBSERVER_HOME}/core/config/common.config.sample.php ${WEBSERVER_HOME}/core/config/common.config.php + sed -i "s/#PASSWORD#/${MYSQL_JEEDOM_PASSWD}/g" ${WEBSERVER_HOME}/core/config/common.config.php + sed -i "s/#DBNAME#/jeedom/g" ${WEBSERVER_HOME}/core/config/common.config.php + sed -i "s/#USERNAME#/jeedom/g" ${WEBSERVER_HOME}/core/config/common.config.php + sed -i "s/#PORT#/3306/g" ${WEBSERVER_HOME}/core/config/common.config.php + sed -i "s/#HOST#/localhost/g" ${WEBSERVER_HOME}/core/config/common.config.php + /root/install.sh -s 10 -v ${VERSION} -w ${WEBSERVER_HOME} + /root/install.sh -s 11 -v ${VERSION} -w ${WEBSERVER_HOME} + fi fi +setTimeZone +#setup apache port +apache_setup +#setup root passwd +set_root_password + echo 'Start atd' service atd restart -service atd status -if [[ $(which mysqld | wc -l) -ne 0 ]]; then +if [ $(which mysqld | wc -l) -ne 0 ]; then echo 'Starting mariadb' chown -R mysql:mysql /var/lib/mysql /var/run/mysqld - service mariadb restart + service_mariadb restart if [ $? -ne 0 ]; then - # That can lead to FATAL corruption of databases - # rm /var/lib/mysql/ib_logfile* - echo "${ROUGE}Starting Database FAILED${NORMAL}" - exit 1 + rm /var/lib/mysql/ib_logfile* + service_mariadb restart fi fi -if [[ ${JEEDOM_INSTALL} == 0 ]] && [[ ! -z "${RESTOREBACKUP}" ]] && [[ "${RESTOREBACKUP}" != 'NO' ]]; then +if [ ${JEEDOM_INSTALL} -eq 0 ] && [ ! -z "${RESTOREBACKUP}" ] && [ "${RESTOREBACKUP}" != 'NO' ]; then echo 'Need restore backup '${RESTOREBACKUP} wget ${RESTOREBACKUP} -O /tmp/backup.tar.gz php ${WEBSERVER_HOME}/install/restore.php backup=/tmp/backup.tar.gz rm /tmp/backup.tar.gz - if [[ ! -z "${UPDATEJEEDOM}" ]] && [[ "${UPDATEJEEDOM}" != 'NO' ]]; then + if [ ! -z "${UPDATEJEEDOM}" ] && [ "${UPDATEJEEDOM}" != 'NO' ]; then echo 'Need update jeedom' php ${WEBSERVER_HOME}/install/update.php fi @@ -98,19 +139,14 @@ fi echo 'All init complete' chmod 777 /dev/tty* +chmod 777 -R /tmp chmod 755 -R ${WEBSERVER_HOME} +chown -R www-data:www-data ${WEBSERVER_HOME} echo 'Start apache2' service apache2 start -service apache2 status -echo 'Start CRON daemon' -cron - -# step_12_jeedom_check -sh /tmp/install.sh -s 12 -v ${VERSION} -w ${WEBSERVER_HOME} -i docker -#TAKE CARE : the init.sh script is running under sh so trap only takes signal_number -echo 'Add trap docker_stop' +echo "Add trap docker_stop" trap "docker_stop $$ ;" 15 -while [[ ! -e "${FILE_STOP}" ]]; do sleep 1; done +cron -f \ No newline at end of file From 3d511ec446f5eb13d5783cff8292ac81d5ea71cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Sat, 7 Sep 2024 11:47:30 +0200 Subject: [PATCH 10/11] fix --- install/OS_specific/Docker/init.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install/OS_specific/Docker/init.sh b/install/OS_specific/Docker/init.sh index ca57203726..1bb9c50f77 100644 --- a/install/OS_specific/Docker/init.sh +++ b/install/OS_specific/Docker/init.sh @@ -23,8 +23,6 @@ service_mariadb(){ docker_stop() { echo "${JAUNE}Stopping Jeedom container${NORMAL}" - echo "${VERT}Killing CRON${NORMAL}" - killall cron echo "${VERT}Stopping Apache gracefully${NORMAL}" service apache2 stop if [[ 1 -eq ${ISMARIABDBINSTALLED} ]]; then @@ -34,7 +32,8 @@ docker_stop() { echo "${VERT}Stopping ATD gracefully${NORMAL}" service atd stop echo "${ROUGE}Requesting stop on init.sh${NORMAL}" - touch ${FILE_STOP} + echo "${VERT}Killing CRON${NORMAL}" + killall cron exit 0 } From bee59864b8f382a7e9dc6a0147baeda7b5489693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc?= <1536036+zoic21@users.noreply.github.com> Date: Sat, 7 Sep 2024 11:51:15 +0200 Subject: [PATCH 11/11] Update Dockerfile --- Dockerfile | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index a5fabd5067..37a75bffed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG DEBIAN=bullseye +ARG DEBIAN=bookworm-slim FROM debian:${DEBIAN} ARG DEBIAN @@ -8,7 +8,15 @@ ENV WEBSERVER_HOME=${WEBSERVER_HOME} ARG VERSION=master ENV VERSION=${VERSION} ARG DATABASE=1 +ENV APACHE_HTTP_PORT=80 +ENV APACHE_HTTPS_PORT=443 ENV DATABASE=${DATABASE} +ENV DB_USERNAME=jeedom +ENV DB_NAME=jeedom +ENV DB_PORT=3306 +ENV DB_HOST=localhost +ENV TZ=America/Chicago +ENV DEBUG=0 # labels follows opencontainers convention LABEL org.opencontainers.image.title='Jeedom' @@ -25,37 +33,35 @@ WORKDIR ${WEBSERVER_HOME} VOLUME ${WEBSERVER_HOME} VOLUME /var/lib/mysql +#speed up build using docker cache +RUN apt update -y +RUN apt -o Dpkg::Options::="--force-confdef" -y install software-properties-common \ + ntp ca-certificates unzip curl sudo cron locate tar telnet wget logrotate dos2unix ntpdate htop \ + iotop vim iftop smbclient git python3 python3-pip libexpat1 ssl-cert \ + apt-transport-https xvfb cutycapt xauth at mariadb-client espeak net-tools nmap ffmpeg usbutils \ + gettext libcurl3-gnutls chromium librsync-dev ssl-cert iputils-ping \ + apache2 apache2-utils libexpat1 ssl-cert \ + php libapache2-mod-php php-json php-mysql php-curl php-gd php-imap php-xml php-opcache php-soap php-xmlrpc \ + php-common php-dev php-zip php-ssh2 php-mbstring php-ldap php-yaml php-snmp && apt -y remove brltty + COPY install/install.sh /tmp/ -# install step by step : step_1_upgrade RUN sh /tmp/install.sh -s 1 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_2_mainpackage RUN sh /tmp/install.sh -s 2 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_3_database RUN sh /tmp/install.sh -s 3 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_4_apache RUN sh /tmp/install.sh -s 4 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_5_php RUN sh /tmp/install.sh -s 5 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step 6 : copy jeedom source files COPY . ${WEBSERVER_HOME} -# step_7_jeedom_customization_mariadb RUN sh /tmp/install.sh -s 7 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_8_jeedom_customization RUN sh /tmp/install.sh -s 8 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_9_jeedom_configuration RUN sh /tmp/install.sh -s 9 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_10_jeedom_installation RUN sh /tmp/install.sh -s 10 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker -# step_11_jeedom_post RUN sh /tmp/install.sh -s 11 -v ${VERSION} -w ${WEBSERVER_HOME} -d ${DATABASE} -i docker +RUN apt-get clean && rm -rf /var/lib/apt/lists/* +RUN echo >${WEBSERVER_HOME}/initialisation -# cleanup -RUN apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# this file is a flag to trigger init.sh initialisation -RUN touch initialisation - +WORKDIR ${WEBSERVER_HOME} EXPOSE 80 -COPY install/OS_specific/Docker/init.sh /root/ -CMD ["bash", "/root/init.sh"] \ No newline at end of file +EXPOSE 443 +COPY --chown=root:root --chmod=550 install/OS_specific/Docker/init.sh /root/ +COPY --chown=root:root --chmod=550 install/bashrc /root/.bashrc +CMD ["bash", "/root/init.sh"]