├── .gitignore ├── LICENSE ├── README.md ├── build ├── Dockerfile ├── build.conf ├── build.sh └── start.sh ├── config ├── piler-default.yml └── piler-ssl.yml ├── install-piler.sh ├── patch.sh ├── piler.conf.example └── update.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .git 2 | .vscode 3 | .DS_Store 4 | piler.conf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 - 2023 simatec 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # piler-docker 2 | 3 | [![License](https://img.shields.io/github/license/simatec/piler-docker?style=flat)](https://github.com/simatec/piler-docker/blob/master/LICENSE) 4 | [![Donate](https://img.shields.io/badge/paypal-donate%20|%20spenden-blue.svg)](https://paypal.me/mk1676) 5 | 6 | 7 | ************************************************************************************************************** 8 | 9 | **If you like it, please consider a donation:** 10 | 11 | [![paypal](https://www.paypalobjects.com/en_US/DK/i/btn/btn_donateCC_LG.gif)](https://paypal.me/mk1676) 12 | 13 | ************************************************************************************************************** 14 | 15 | 16 | ### Mailpiler for Docker 17 | 18 | This is a project to get the Mailpiler running in a docker compose system in a simple and uncomplicated way. 19 | 20 | You can find more information about the Piler project here. 21 | 22 | https://www.mailpiler.org/ or https://github.com/jsuto/piler 23 | 24 | ******************************************************************************************************* 25 | 26 | ### DockerHub 27 | 28 | https://hub.docker.com/r/simatec/piler 29 | 30 | ******************************************************************************************************* 31 | 32 | 33 | ### Installation Guide: 34 | 35 | * Install Docker and dependencies 36 | 37 | ``` 38 | apt install curl git -y 39 | ``` 40 | 41 | ``` 42 | curl -sSL https://get.docker.com/ | CHANNEL=stable sh 43 | ``` 44 | ``` 45 | systemctl enable --now docker 46 | ``` 47 | 48 | * Install Docker-Compose 49 | 50 | ``` 51 | curl -L https://github.com/docker/compose/releases/download/v$(curl -Ls https://www.servercow.de/docker-compose/latest.php)/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose 52 | ``` 53 | ``` 54 | chmod +x /usr/local/bin/docker-compose 55 | ``` 56 | 57 | * reboot your system 58 | 59 | ``` 60 | reboot now 61 | ``` 62 | 63 | * Clone repository 64 | 65 | ``` 66 | cd /opt 67 | ``` 68 | ``` 69 | git clone https://github.com/simatec/piler-docker.git 70 | ``` 71 | ``` 72 | cd /opt/piler-docker 73 | ``` 74 | 75 | 76 | * start the Install 77 | 78 | ``` 79 | bash install-piler.sh 80 | ``` 81 | 82 | 83 | Congratulations your Piler is installed... 84 | 85 | If you have Let's Encrypt activated, you can reach the Piler at https://your-piler-domain 86 | 87 | If Let's Encrypt is disabled, the Piler is at http://your-piler-domain or at http://your-local-IP 88 | 89 | The Default Login is `admin@local` and the Password ist `pilerrocks` 90 | 91 | 92 | > After installation, any changes can be made in piler.conf at any time and the install script can then be run again. 93 | 94 | 95 | ********************************************************************************************************** 96 | 97 | 98 | ### Update Guide: 99 | 100 | You can execute the following commands to update the containers. 101 | Here the current yml files are downloaded from Github and the containers are updated if necessary. 102 | 103 | ``` 104 | cd /opt/piler-docker 105 | bash install-piler.sh 106 | ``` 107 | You will get a selection menu with the following options: 108 | 109 | ``` 110 | 1) Install-Piler 111 | 2) Update-Piler 112 | ``` 113 | 114 | * After a successful update, unused container images can be removed from the system with the following command: 115 | 116 | ``` 117 | docker system prune 118 | ``` 119 | 120 | ********************************************************************************************************** 121 | 122 | ### Using the Piler on the command line 123 | 124 | For use on the command line, we first log into the container. 125 | 126 | ``` 127 | docker exec -it piler /bin/bash 128 | ``` 129 | 130 | Next we switch to the user "piler" 131 | 132 | ``` 133 | su piler 134 | ``` 135 | 136 | To get write permissions, we switch to the /var/tmp folder 137 | 138 | ``` 139 | cd /var/tmp 140 | ``` 141 | 142 | Here you can now execute the functions of the Piler on the command line. 143 | Here are some examples: 144 | 145 | ``` 146 | pilerimport -h 147 | crontab -l 148 | ``` 149 | 150 | To leave the container on the console you have to execute 2x `exit`. 151 | 152 | 153 | ********************************************************************************************************** 154 | 155 | ## Changelog 156 | 157 | ### 0.9.7 (14.06.2024) 158 | * (simatec) Fix Network on Update 159 | 160 | ### 0.9.7 (14.06.2024) 161 | * (simatec) Release 0.9.7 162 | 163 | ### 0.9.6 (11.06.2024) 164 | * (simatec) Hostname Fix 165 | 166 | ### 0.9.5 (10.06.2024) 167 | * (simatec) small fix 168 | 169 | ### 0.9.4 (05.06.2024) 170 | * (simatec) patch for Piler Update added 171 | 172 | ### 0.9.3 (01.06.2024) 173 | * (simatec) Piler v1.4.5 updated 174 | * (simatec) MariaDB v11.1.2 updated 175 | 176 | ### 0.9.2 (19.09.2023) 177 | * (simatec) Piler v1.4.4 updated 178 | 179 | ### 0.9.1 (23.01.2023) 180 | * (simatec) Piler updated 181 | 182 | ### 0.9.1 (23.01.2023) 183 | * (simatec) Piler Docker Hub added 184 | * (simatec) Fix Automatic Import 185 | 186 | ### 0.9.0 (23.01.2023) 187 | * (simatec) Piler Build added 188 | * (simatec) Piler Import Option added 189 | * (simatec) Fix Updater 190 | 191 | ### 0.8.3 (19.01.2023) 192 | * (simatec) Update himself added 193 | 194 | ### 0.8.2 (18.01.2023) 195 | * (simatec) docker, curl and git Check added 196 | * (simatec) Update Config added 197 | 198 | ### 0.8.1 (17.01.2023) 199 | * (simatec) Docker Compose Check added 200 | 201 | ### 0.8.0 (17.01.2023) 202 | * (simatec) Config-Menu for Installer added 203 | 204 | ### 0.7.0 (15.01.2023) 205 | * (simatec) New Volumes added 206 | * (simatec) Fix Installer 207 | 208 | ### 0.6.0 (18.12.2022) 209 | * (simatec) Update Installer 210 | * (simatec) update.sh added 211 | * (simatec) downgrade mariadb to v10.6 212 | 213 | ### 0.5.3 (17.12.2022) 214 | * (simatec) Installer Fix 215 | 216 | ### 0.5.2 (16.12.2022) 217 | * (simatec) update piler to v1.4.2 218 | 219 | ### 0.5.1 (15.12.2022) 220 | * (simatec) update piler to v1.4.1 221 | * (simatec) update mariadb to v10.9.4 222 | 223 | ### 0.5.0 (25.08.2022) 224 | * (simatec) update piler to 1.3.12 225 | * (simatec) update mariadb to 10.9.2 226 | 227 | ### 0.4.0 (20.04.2022) 228 | * (simatec) small fixes 229 | 230 | ### 0.3.0 (10.03.2022) 231 | * (simatec) purge option added to config 232 | 233 | ### 0.2.0 (09.03.2022) 234 | * (simatec) Let's Encrypt added 235 | 236 | ### 0.1.0 (08.03.2022) 237 | * (simatec) first beta 238 | 239 | ## License 240 | MIT License 241 | 242 | Copyright (c) 2022 - 2024 simatec 243 | 244 | Permission is hereby granted, free of charge, to any person obtaining a copy 245 | of this software and associated documentation files (the "Software"), to deal 246 | in the Software without restriction, including without limitation the rights 247 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 248 | copies of the Software, and to permit persons to whom the Software is 249 | furnished to do so, subject to the following conditions: 250 | 251 | The above copyright notice and this permission notice shall be included in all 252 | copies or substantial portions of the Software. 253 | 254 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 255 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 256 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 257 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 258 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 259 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 260 | SOFTWARE. -------------------------------------------------------------------------------- /build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | ARG PACKAGE 4 | ARG TARGETARCH 5 | 6 | LABEL description="piler ubuntu jammy image" \ 7 | maintainer="Janos SUTO, sj@acts.hu" \ 8 | package="${PACKAGE}" 9 | 10 | ENV DEBIAN_FRONTEND="noninteractive" \ 11 | DISTRO="jammy" \ 12 | PILER_USER="piler" \ 13 | MYSQL_DATABASE="piler" 14 | 15 | COPY ${PACKAGE}_${TARGETARCH}.deb / 16 | 17 | # hadolint ignore=DL3008 18 | RUN apt-get update && \ 19 | apt-get -y --no-install-recommends install \ 20 | wget openssl sysstat php8.1-cli php8.1-cgi php8.1-mysql php8.1-fpm php8.1-zip php8.1-ldap \ 21 | php8.1-gd php8.1-curl php8.1-xml php8.1-memcached catdoc unrtf poppler-utils nginx tnef sudo libzip4 \ 22 | libtre5 cron libmariadb-dev mariadb-client-core-10.6 python3 python3-mysqldb ca-certificates curl rsyslog && \ 23 | wget https://repo.manticoresearch.com/manticore-repo.noarch.deb && \ 24 | dpkg -i manticore-repo.noarch.deb && \ 25 | rm -f manticore-repo.noarch.deb && \ 26 | apt-get update && \ 27 | apt-get install -y --no-install-recommends manticore manticore-columnar-lib && \ 28 | apt-get clean && \ 29 | rm -rf /var/lib/apt/lists/* && \ 30 | sed -i '/session required pam_loginuid.so/c\#session required pam_loginuid.so' /etc/pam.d/cron && \ 31 | dpkg -i ${PACKAGE}_${TARGETARCH}.deb && \ 32 | touch /etc/piler/MANTICORE && \ 33 | ln -sf /etc/piler/piler-nginx.conf /etc/nginx/sites-enabled && \ 34 | rm -f ${PACKAGE}_${TARGETARCH}.deb /etc/nginx/sites-enabled/default /etc/piler/piler.key /etc/piler/piler.pem /etc/piler/config-site.php && \ 35 | crontab -u $PILER_USER /usr/share/piler/piler.cron 36 | 37 | VOLUME ["/etc/piler","/var/piler/store","/var/piler/manticore","/var/piler/imap","/var/piler/stat","/var/spool/cron/crontabs"] 38 | 39 | EXPOSE 25/tcp 40 | EXPOSE 80/tcp 41 | EXPOSE 443/tcp 42 | 43 | # Clean up APT when done. 44 | RUN apt clean && \ 45 | apt autoremove && \ 46 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 47 | 48 | RUN sed -i '/imklog/ s/^/#/' /etc/rsyslog.conf 49 | 50 | COPY start.sh /start.sh 51 | 52 | # chmod start.sh 53 | RUN chmod a+x /start.sh 54 | 55 | CMD ["/start.sh"] 56 | -------------------------------------------------------------------------------- /build/build.conf: -------------------------------------------------------------------------------- 1 | # Piler Package 2 | 3 | PILER_PACKAGE="piler_1.4.5-jammy-c13432f_amd64.deb" 4 | 5 | # Piler Version 6 | 7 | PILER_VERSION="1.4.5" 8 | 9 | # MariaDB Version 10 | 11 | MARIA_DB_VERSION="11.4" -------------------------------------------------------------------------------- /build/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Path Settings 4 | buildPth=`pwd` 5 | 6 | cd $buildPth 7 | 8 | # chmod start.sh 9 | chmod a+x start.sh 10 | 11 | # build config load 12 | . ./build.conf 13 | 14 | # set Piler Version 15 | #sed -i 's/PILER_VERSION=.*/PILER_VERSION="'$PILER_VERSION'"/g' ../piler.conf 16 | 17 | # set Maria-DB Version 18 | #sed -i 's/MARIA_DB_VERSION=.*/MARIA_DB_VERSION="'$MARIA_DB_VERSION'"/g' ../piler.conf 19 | 20 | 21 | # Package Download 22 | rm -f $buildPth/*.deb 23 | 24 | #curl -OL https://bitbucket.org/jsuto/piler/downloads/$PILER_PACKAGE 25 | wget https://bitbucket.org/jsuto/piler/downloads/$PILER_PACKAGE -O $PILER_PACKAGE 26 | 27 | set -o errexit 28 | set -o pipefail 29 | set -o nounset 30 | 31 | IMAGE_NAME="simatec/piler:$PILER_VERSION" 32 | 33 | if [ ! -f $buildPth/$PILER_PACKAGE ]; then 34 | echo "ERROR: missing package name" 1>&2; exit 1; 35 | fi 36 | 37 | docker build --build-arg PACKAGE="$PILER_PACKAGE" -t "$IMAGE_NAME" . 38 | exit 0 39 | -------------------------------------------------------------------------------- /build/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o pipefail 5 | set -o nounset 6 | 7 | CONFIG_DIR="/etc/piler" 8 | VOLUME_DIR="/var/piler" 9 | PILER_CONF="${CONFIG_DIR}/piler.conf" 10 | PILER_KEY="${CONFIG_DIR}/piler.key" 11 | PILER_PEM="${CONFIG_DIR}/piler.pem" 12 | PILER_NGINX_CONF="${CONFIG_DIR}/piler-nginx.conf" 13 | SPHINX_CONF="${CONFIG_DIR}/manticore.conf" 14 | CONFIG_SITE_PHP="${CONFIG_DIR}/config-site.php" 15 | PILER_MY_CNF="${CONFIG_DIR}/.my.cnf" 16 | RT="${RT:-0}" 17 | 18 | error() { 19 | echo "ERROR:" "$*" 1>&2 20 | exit 1 21 | } 22 | 23 | 24 | log() { 25 | echo "DEBUG:" "$*" 26 | } 27 | 28 | 29 | pre_flight_check() { 30 | [[ -v PILER_HOSTNAME ]] || error "Missing PILER_HOSTNAME env variable" 31 | [[ -v MYSQL_HOSTNAME ]] || error "Missing MYSQL_HOSTNAME env variable" 32 | [[ -v MYSQL_DATABASE ]] || error "Missing MYSQL_DATABASE env variable" 33 | [[ -v MYSQL_USER ]] || error "Missing MYSQL_USER env variable" 34 | [[ -v MYSQL_PASSWORD ]] || error "Missing MYSQL_PASSWORD env variable" 35 | } 36 | 37 | 38 | give_it_to_piler() { 39 | local f="$1" 40 | 41 | [[ -f "$f" ]] || error "${f} does not exist, aborting" 42 | 43 | chown "${PILER_USER}:${PILER_USER}" "$f" 44 | chmod 600 "$f" 45 | } 46 | 47 | 48 | make_certificate() { 49 | local f="$1" 50 | local crt="/tmp/1.cert" 51 | local SSL_CERT_DATA="/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" 52 | 53 | log "Making an ssl certificate" 54 | 55 | openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "$SSL_CERT_DATA" -keyout "$f" -out "$crt" -sha1 2>/dev/null 56 | cat "$crt" >> "$f" 57 | rm -f "$crt" 58 | 59 | give_it_to_piler "$f" 60 | } 61 | 62 | 63 | make_piler_key() { 64 | local f="$1" 65 | 66 | log "Generating piler.key" 67 | 68 | dd if=/dev/urandom bs=56 count=1 of="$f" 2>/dev/null 69 | [[ $(stat -c '%s' "$f") -eq 56 ]] || error "could not read 56 bytes from /dev/urandom to ${f}" 70 | 71 | give_it_to_piler "$f" 72 | } 73 | 74 | 75 | fix_configs() { 76 | [[ -f "$PILER_KEY" ]] || make_piler_key "$PILER_KEY" 77 | [[ -f "$PILER_PEM" ]] || make_certificate "$PILER_PEM" 78 | 79 | if [[ ! -f "$PILER_NGINX_CONF" ]]; then 80 | log "Writing ${PILER_NGINX_CONF}" 81 | 82 | cp "${PILER_NGINX_CONF}.dist" "$PILER_NGINX_CONF" 83 | sed -i "s%PILER_HOST%${PILER_HOSTNAME}%" "$PILER_NGINX_CONF" 84 | fi 85 | 86 | if [[ ! -f "$PILER_CONF" ]]; then 87 | log "Writing ${PILER_CONF}" 88 | 89 | sed \ 90 | -e "s/mysqluser=.*/mysqluser=${MYSQL_USER}/g" \ 91 | -e "s/mysqldb=.*/mysqldb=${MYSQL_DATABASE}/g" \ 92 | -e "s/verystrongpassword/${MYSQL_PASSWORD}/g" \ 93 | -e "s/hostid=.*/hostid=${PILER_HOSTNAME}/g" \ 94 | -e "s/tls_enable=.*/tls_enable=1/g" \ 95 | -e "s/mysqlsocket=.*/mysqlsocket=/g" "${PILER_CONF}.dist" > "$PILER_CONF" 96 | 97 | { 98 | echo "mysqlhost=${MYSQL_HOSTNAME}" 99 | } >> "$PILER_CONF" 100 | 101 | give_it_to_piler "$PILER_CONF" 102 | fi 103 | 104 | if [[ ! -f "$CONFIG_SITE_PHP" ]]; then 105 | log "Writing ${CONFIG_SITE_PHP}" 106 | 107 | cp "${CONFIG_DIR}/config-site.dist.php" "$CONFIG_SITE_PHP" 108 | 109 | sed -i "s%HOSTNAME%${PILER_HOSTNAME}%" "$CONFIG_SITE_PHP" 110 | 111 | { 112 | echo "\$config['DECRYPT_BINARY'] = '/usr/bin/pilerget';" 113 | echo "\$config['DECRYPT_ATTACHMENT_BINARY'] = '/usr/bin/pileraget';" 114 | echo "\$config['PILER_BINARY'] = '/usr/sbin/piler';" 115 | echo "\$config['DB_HOSTNAME'] = '$MYSQL_HOSTNAME';" 116 | echo "\$config['DB_DATABASE'] = '$MYSQL_DATABASE';" 117 | echo "\$config['DB_USERNAME'] = '$MYSQL_USER';" 118 | echo "\$config['DB_PASSWORD'] = '$MYSQL_PASSWORD';" 119 | echo "\$config['ENABLE_MEMCACHED'] = 1;" 120 | echo "\$memcached_server = ['memcached', 11211];" 121 | } >> "$CONFIG_SITE_PHP" 122 | fi 123 | 124 | sed -e "s%MYSQL_HOSTNAME%${MYSQL_HOSTNAME}%" \ 125 | -e "s%MYSQL_DATABASE%${MYSQL_DATABASE}%" \ 126 | -e "s%MYSQL_USERNAME%${MYSQL_USER}%" \ 127 | -e "s%MYSQL_PASSWORD%${MYSQL_PASSWORD}%" \ 128 | -i "$SPHINX_CONF" 129 | 130 | # Fixes for RT index 131 | 132 | if [[ $RT -eq 1 ]]; then 133 | sed -i "s/define('RT', 0)/define('RT', 1)/" "$SPHINX_CONF" 134 | if ! grep "'RT'" "$CONFIG_SITE_PHP"; then 135 | echo "\$config['RT'] = 1;" >> "$CONFIG_SITE_PHP" 136 | fi 137 | 138 | if ! grep "'SPHINX_MAIN_INDEX'" "$CONFIG_SITE_PHP"; then 139 | echo "\$config['SPHINX_MAIN_INDEX'] = 'piler1';" >> "$CONFIG_SITE_PHP" 140 | fi 141 | 142 | sed -i "s%rtindex=.*%rtindex=1%" "$PILER_CONF" 143 | fi 144 | } 145 | 146 | 147 | wait_until_mysql_server_is_ready() { 148 | while true; do if mysql "--defaults-file=${PILER_MY_CNF}" <<< "show databases"; then break; fi; log "${MYSQL_HOSTNAME} is not ready"; sleep 5; done 149 | 150 | log "${MYSQL_HOSTNAME} is ready" 151 | } 152 | 153 | 154 | init_database() { 155 | local table 156 | local has_metadata_table=0 157 | 158 | wait_until_mysql_server_is_ready 159 | 160 | while read -r table; do 161 | if [[ "$table" == metadata ]]; then has_metadata_table=1; fi 162 | done < <(mysql "--defaults-file=${PILER_MY_CNF}" "$MYSQL_DATABASE" <<< 'show tables') 163 | 164 | if [[ $has_metadata_table -eq 0 ]]; then 165 | log "no metadata table, creating tables" 166 | 167 | mysql "--defaults-file=${PILER_MY_CNF}" "$MYSQL_DATABASE" < /usr/share/piler/db-mysql.sql 168 | else 169 | log "metadata table exists" 170 | fi 171 | 172 | if [[ -v ADMIN_USER_PASSWORD_HASH ]]; then 173 | mysql "--defaults-file=${PILER_MY_CNF}" "$MYSQL_DATABASE" <<< "update user set password='${ADMIN_USER_PASSWORD_HASH}' where uid=0" 174 | fi 175 | } 176 | 177 | 178 | create_my_cnf_files() { 179 | printf "[client]\nhost = %s\nuser = %s\npassword = %s\n[mysqldump]\nhost = %s\nuser = %s\npassword = %s\n" \ 180 | "$MYSQL_HOSTNAME" "$MYSQL_USER" "$MYSQL_PASSWORD" "$MYSQL_HOSTNAME" "$MYSQL_USER" "$MYSQL_PASSWORD" \ 181 | > "$PILER_MY_CNF" 182 | 183 | give_it_to_piler "$PILER_MY_CNF" 184 | } 185 | 186 | 187 | start_services() { 188 | service cron start 189 | service php8.1-fpm start 190 | service nginx start 191 | rsyslogd 192 | } 193 | 194 | 195 | start_piler() { 196 | if [[ $RT -eq 0 && ! -f "${VOLUME_DIR}/manticore/main1.spp" ]]; then 197 | log "main1.spp does not exist, creating index files" 198 | su -c "indexer --all --config ${SPHINX_CONF}" "$PILER_USER" 199 | fi 200 | 201 | # No pid file should exist for piler 202 | rm -f /var/run/piler/*pid 203 | 204 | /etc/init.d/rc.searchd start 205 | /etc/init.d/rc.piler start 206 | } 207 | 208 | 209 | pre_flight_check 210 | fix_configs 211 | create_my_cnf_files 212 | init_database 213 | start_services 214 | start_piler 215 | 216 | sleep infinity -------------------------------------------------------------------------------- /config/piler-default.yml: -------------------------------------------------------------------------------- 1 | services: 2 | mysql: 3 | image: mariadb:${MARIA_DB_VERSION} 4 | container_name: mysql_piler 5 | restart: unless-stopped 6 | networks: 7 | - pilernet 8 | cap_drop: 9 | - ALL 10 | cap_add: 11 | - dac_override 12 | - setuid 13 | - setgid 14 | environment: 15 | - MYSQL_DATABASE=${MYSQL_DATABASE} 16 | - MYSQL_USER=${MYSQL_USER} 17 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 18 | - MYSQL_RANDOM_ROOT_PASSWORD=yes 19 | - TZ="Europe/Berlin" 20 | - MARIADB_AUTO_UPGRADE=1 21 | - MARIADB_DISABLE_UPGRADE_BACKUP=1 22 | command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 23 | healthcheck: 24 | test: mariadb --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} piler --execute "show tables" 25 | interval: "60s" 26 | timeout: "5s" 27 | start_period: "15s" 28 | retries: 3 29 | volumes: 30 | - db_data:/var/lib/mysql 31 | 32 | memcached: 33 | image: memcached:latest 34 | container_name: memcached_piler 35 | restart: unless-stopped 36 | networks: 37 | - pilernet 38 | cap_drop: 39 | - ALL 40 | command: -m 64 41 | 42 | piler: 43 | image: simatec/piler:${PILER_VERSION} 44 | container_name: piler 45 | restart: unless-stopped 46 | networks: 47 | - pilernet 48 | hostname: ${PILER_DOMAIN} 49 | init: true 50 | environment: 51 | - MEMCACHED_HOSTNAME=memcached 52 | - MYSQL_DATABASE=${MYSQL_DATABASE} 53 | - MYSQL_USER=${MYSQL_USER} 54 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 55 | - MYSQL_HOSTNAME=mysql_piler 56 | - PILER_HOSTNAME=${PILER_DOMAIN} 57 | - MEMCACHED_HOST=memcached_piler 58 | - TZ=${TIME_ZONE} 59 | - RT=1 60 | ports: 61 | - "25:25" 62 | - "80:80" 63 | - "443:443" 64 | volumes: 65 | - piler_etc:/etc/piler 66 | - piler_var_store:/var/piler/store 67 | - piler_var_manticore:/var/piler/manticore 68 | - piler_var_imap:/var/piler/imap 69 | - piler_var_stat:/var/piler/stat 70 | - piler_cron:/var/spool/cron/crontabs 71 | - /etc/localtime:/etc/localtime:ro 72 | healthcheck: 73 | test: curl -s smtp://localhost/ 74 | interval: "60s" 75 | timeout: "3s" 76 | start_period: "15s" 77 | retries: 3 78 | deploy: 79 | resources: 80 | reservations: 81 | memory: 512M 82 | limits: 83 | memory: 512M 84 | depends_on: 85 | - memcached 86 | - mysql 87 | 88 | networks: 89 | pilernet: 90 | external: true 91 | 92 | volumes: 93 | db_data: 94 | piler_etc: 95 | piler_var_store: 96 | piler_var_manticore: 97 | piler_var_imap: 98 | piler_var_stat: 99 | piler_cron: 100 | -------------------------------------------------------------------------------- /config/piler-ssl.yml: -------------------------------------------------------------------------------- 1 | services: 2 | nginx-proxy: 3 | image: jwilder/nginx-proxy 4 | container_name: nginx-proxy 5 | restart: unless-stopped 6 | networks: 7 | - pilernet 8 | ports: 9 | - "80:80" 10 | - "443:443" 11 | volumes: 12 | - ./nginx-data/certs:/etc/nginx/certs 13 | - ./nginx-data/vhost.d:/etc/nginx/vhost.d 14 | - ./nginx-data/html:/usr/share/nginx/html 15 | - /var/run/docker.sock:/tmp/docker.sock:ro 16 | 17 | nginx-letsencrypt: 18 | image: jrcs/letsencrypt-nginx-proxy-companion 19 | container_name: nginx-letsencrypt 20 | restart: unless-stopped 21 | networks: 22 | - pilernet 23 | volumes_from: 24 | - nginx-proxy 25 | volumes: 26 | - /var/run/docker.sock:/var/run/docker.sock:ro 27 | environment: 28 | - DEFAULT_EMAIL=${LETSENCRYPT_EMAIL} 29 | 30 | mysql: 31 | image: mariadb:${MARIA_DB_VERSION} 32 | container_name: mysql_piler 33 | restart: unless-stopped 34 | networks: 35 | - pilernet 36 | cap_drop: 37 | - ALL 38 | cap_add: 39 | - dac_override 40 | - setuid 41 | - setgid 42 | environment: 43 | - MYSQL_DATABASE=${MYSQL_DATABASE} 44 | - MYSQL_USER=${MYSQL_USER} 45 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 46 | - MYSQL_RANDOM_ROOT_PASSWORD=yes 47 | - TZ="Europe/Berlin" 48 | - MARIADB_AUTO_UPGRADE=1 49 | - MARIADB_DISABLE_UPGRADE_BACKUP=1 50 | command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 51 | healthcheck: 52 | test: mariadb --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} piler --execute "show tables" 53 | interval: "60s" 54 | timeout: "5s" 55 | start_period: "15s" 56 | retries: 3 57 | volumes: 58 | - db_data:/var/lib/mysql 59 | 60 | memcached: 61 | image: memcached:latest 62 | container_name: memcached_piler 63 | restart: unless-stopped 64 | networks: 65 | - pilernet 66 | cap_drop: 67 | - ALL 68 | command: -m 64 69 | 70 | piler: 71 | image: simatec/piler:${PILER_VERSION} 72 | container_name: piler 73 | restart: unless-stopped 74 | networks: 75 | - pilernet 76 | expose: 77 | - "80" 78 | hostname: ${PILER_DOMAIN} 79 | init: true 80 | environment: 81 | - MYSQL_DATABASE=${MYSQL_DATABASE} 82 | - MYSQL_USER=${MYSQL_USER} 83 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 84 | - MYSQL_HOSTNAME=mysql_piler 85 | - PILER_HOSTNAME=${PILER_DOMAIN} 86 | - MEMCACHED_HOST=memcached_piler 87 | - TZ=${TIME_ZONE} 88 | - RT=1 89 | - VIRTUAL_HOST=${PILER_DOMAIN} 90 | - LETSENCRYPT_HOST=${PILER_DOMAIN} 91 | - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} 92 | ports: 93 | - "25:25" 94 | volumes: 95 | - piler_etc:/etc/piler 96 | - piler_var_store:/var/piler/store 97 | - piler_var_manticore:/var/piler/manticore 98 | - piler_var_imap:/var/piler/imap 99 | - piler_var_stat:/var/piler/stat 100 | - piler_cron:/var/spool/cron/crontabs 101 | - /etc/localtime:/etc/localtime:ro 102 | healthcheck: 103 | test: curl -s smtp://localhost/ 104 | interval: "60s" 105 | timeout: "3s" 106 | start_period: "15s" 107 | retries: 3 108 | deploy: 109 | resources: 110 | reservations: 111 | memory: 512M 112 | limits: 113 | memory: 512M 114 | depends_on: 115 | - memcached 116 | - mysql 117 | 118 | networks: 119 | pilernet: 120 | external: true 121 | 122 | volumes: 123 | db_data: 124 | piler_etc: 125 | piler_var_store: 126 | piler_var_manticore: 127 | piler_var_imap: 128 | piler_var_stat: 129 | piler_cron: 130 | -------------------------------------------------------------------------------- /install-piler.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Colors 4 | if [ -z ${BASH_SOURCE} ]; then 5 | blue=`echo "\e[1m\e[34m"` 6 | green=`echo "\e[1m\e[32m"` 7 | greenBold=`echo "\e[1m\e[1;32m"` 8 | redBold=`echo "\e[1m\e[1;31m"` 9 | red=`echo "\e[1m\e[31m"` 10 | purple=`echo "\e[1m\e[35m"` 11 | bold=`echo "\e[1m"` 12 | normal=`echo "\e[0m"` 13 | else 14 | blue=`echo -e "\e[1m\e[34m"` 15 | green=`echo -e "\e[1m\e[32m"` 16 | greenBold=`echo -e "\e[1m\e[1;32m"` 17 | redBold=`echo -e "\e[1m\e[1;31m"` 18 | purple=`echo -e "\e[1m\e[35m"` 19 | bold=`echo -e "\e[1m"` 20 | normal=`echo -en "\e[0m"` 21 | fi 22 | 23 | HLINE="================================================================" 24 | HLINE_SMALL="=================================" 25 | 26 | BLA_metro=( 0.2 ' ' '= ' '== ' '=== ' ' ===' ' ==' ' =' ) 27 | 28 | BLA::play_loading_animation_loop() { 29 | while true ; do 30 | for frame in "${BLA_active_loading_animation[@]}" ; do 31 | printf "\r%s" "${frame}" 32 | sleep "${BLA_loading_animation_frame_interval}" 33 | done 34 | done 35 | } 36 | 37 | BLA::start_loading_animation() { 38 | BLA_active_loading_animation=( "${@}" ) 39 | BLA_loading_animation_frame_interval="${BLA_active_loading_animation[0]}" 40 | unset "BLA_active_loading_animation[0]" 41 | tput civis # Hide the terminal cursor 42 | BLA::play_loading_animation_loop & 43 | BLA_loading_animation_pid="${!}" 44 | } 45 | 46 | BLA::stop_loading_animation() { 47 | kill "${BLA_loading_animation_pid}" &> /dev/null 48 | printf "\n" 49 | tput cnorm # Restore the terminal cursor 50 | } 51 | 52 | ####################################################################################### 53 | 54 | function header_info { 55 | clear 56 | 57 | echo "${greenBold}" 58 | cat <<"EOF" 59 | 60 | _ _ ___ _ _ _ 61 | _ __ (_) | ___ _ __ |_ _|_ __ ___| |_ __ _| | | ___ _ __ 62 | | '_ \| | |/ _ \ '__| | || '_ \/ __| __/ _` | | |/ _ \ '__| 63 | | |_) | | | __/ | | || | | \__ \ || (_| | | | __/ | 64 | | .__/|_|_|\___|_| |___|_| |_|___/\__\__,_|_|_|\___|_| 65 | |_| 66 | 67 | EOF 68 | echo "${normal}" 69 | } 70 | header_info 71 | 72 | ####################################################################################### 73 | 74 | # App Check 75 | for bin in curl docker git; do 76 | if [[ -z $(which ${bin}) ]]; then echo "${redBold}Cannot find ${bin}, exiting...${normal}"; exit 1; fi 77 | done 78 | 79 | # Docker-Compose Check 80 | if docker compose > /dev/null 2>&1; then 81 | if docker compose version --short | grep "^2." > /dev/null 2>&1; then 82 | COMPOSE_VERSION=native 83 | echo -e "${purple}Found Docker Compose Plugin (native).${normal}" 84 | echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to native${normal}" 85 | sleep 2 86 | echo -e "${purple}Notice: You´ll have to update this Compose Version via your Package Manager manually!${normal}" 87 | else 88 | echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}" 89 | exit 1 90 | fi 91 | elif docker-compose > /dev/null 2>&1; then 92 | if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then 93 | if docker-compose version --short | grep "^2." > /dev/null 2>&1; then 94 | COMPOSE_VERSION=standalone 95 | echo -e "${purple}Found Docker Compose Standalone.${normal}" 96 | echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to standalone${normal}" 97 | sleep 2 98 | else 99 | echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}" 100 | exit 1 101 | fi 102 | fi 103 | 104 | else 105 | echo -e "${redBold}Cannot find Docker Compose.${normal}" 106 | exit 1 107 | fi 108 | 109 | ####################################################################################### 110 | 111 | # Path-Settings 112 | installPth=`pwd` 113 | configPth="$installPth/config" 114 | etcPth="/var/lib/docker/volumes/piler-docker_piler_etc/_data" 115 | cronPth="/var/lib/docker/volumes/piler-docker_piler_cron/_data" 116 | buildPth="$installPth/build" 117 | 118 | ############################## Installer Settings ###################################### 119 | 120 | if [ ! -f $installPth/.configDone ]; then 121 | 122 | # create config 123 | if [ ! -f $installPth/piler.conf ]; then 124 | if [ -f $installPth/piler.conf.example ]; then 125 | cp $installPth/piler.conf.example $installPth/piler.conf 126 | fi 127 | fi 128 | 129 | # Load config 130 | . ./piler.conf 131 | 132 | # Piler-Domain 133 | read -ep "Please set your Piler-Domain (Enter for default: $PILER_DOMAIN): " pilerDomain 134 | pilerDomain=${pilerDomain:=$PILER_DOMAIN} 135 | sed -i 's/PILER_DOMAIN=.*/PILER_DOMAIN="'$pilerDomain'"/g' ./piler.conf 136 | 137 | # Piler-Admin-Mail 138 | read -ep "Please set your Mailserver Admin Mail (Enter for default: $SUPPORT_MAIL): " pilerAdminMail 139 | pilerAdminMail=${pilerAdminMail:=$SUPPORT_MAIL} 140 | sed -i 's/SUPPORT_MAIL=.*/SUPPORT_MAIL="'$pilerAdminMail'"/g' ./piler.conf 141 | 142 | # retention Days 143 | read -ep "Please set retention days (Enter for default: $DEFAULT_RETENTION_DAYS Days): " retentionDays 144 | retentionDays=${retentionDays:=$DEFAULT_RETENTION_DAYS} 145 | sed -i 's/DEFAULT_RETENTION_DAYS=.*/DEFAULT_RETENTION_DAYS="'$retentionDays'"/g' ./piler.conf 146 | 147 | # Smarthost 148 | read -ep "Please set your Smarthost (Enter for default: $SMARTHOST). Default settings can be used here!!: " pilerSmartHost 149 | pilerSmartHost=${pilerSmartHost:=$SMARTHOST} 150 | sed -i 's/SMARTHOST=.*/SMARTHOST="'$pilerSmartHost'"/g' ./piler.conf 151 | 152 | # IMAP Server 153 | read -ep "Please set your IMAP Server (Enter for default: $IMAP_SERVER): " imapServer 154 | imapServer=${imapServer:=$IMAP_SERVER} 155 | sed -i 's/IMAP_SERVER=.*/IMAP_SERVER="'$imapServer'"/g' ./piler.conf 156 | 157 | # Timezone 158 | read -ep "Please set your Timezone (Enter for default: $TIME_ZONE): " timeZone 159 | timeZone=${timeZone:=$TIME_ZONE} 160 | timeZone="${timeZone////\\/}" 161 | sed -i 's/TIME_ZONE=.*/TIME_ZONE="'$timeZone'"/g' ./piler.conf 162 | 163 | # MySql Database 164 | read -ep "Please set your MySql Database (Enter for default: $MYSQL_DATABASE): " pilerDataBase 165 | pilerDataBase=${pilerDataBase:=$MYSQL_DATABASE} 166 | sed -i 's/MYSQL_DATABASE=.*/MYSQL_DATABASE="'$pilerDataBase'"/g' ./piler.conf 167 | 168 | # MySql User 169 | read -ep "Please set your MySql User (Enter for default: $MYSQL_USER): " pilerUser 170 | pilerUser=${pilerUser:=$MYSQL_USER} 171 | sed -i 's/MYSQL_USER=.*/MYSQL_USER="'$pilerUser'"/g' ./piler.conf 172 | 173 | # MySql Password 174 | read -sp "Please set your MySql Password: " pilerPassword 175 | pilerPassword=$pilerPassword 176 | sed -i 's/MYSQL_PASSWORD=.*/MYSQL_PASSWORD="'$pilerPassword'"/g' ./piler.conf 177 | echo 178 | 179 | # use Let's Encrypt 180 | while true; do 181 | read -ep "Enabled / Disabled (yes/no) Let's Encrypt? For local Run disabled / Y|N: " jn 182 | case $jn in 183 | [Yy]* ) sed -i 's/USE_LETSENCRYPT=.*/USE_LETSENCRYPT="yes"/g' ./piler.conf; break;; 184 | [Nn]* ) sed -i 's/USE_LETSENCRYPT=.*/USE_LETSENCRYPT="no"/g' ./piler.conf; break;; 185 | * ) echo -e "${redBold} Please confirm with Y or N.${normal}";; 186 | esac 187 | done 188 | 189 | # reload config 190 | . ./piler.conf 191 | 192 | # Let's Encrypt registration contact information 193 | if [ "$USE_LETSENCRYPT" = "yes" ]; then 194 | read -ep "Please set Let's Encrypt registration contact information (Enter for default: $LETSENCRYPT_EMAIL): " acmeContact 195 | acmeContact=${acmeContact:=$LETSENCRYPT_EMAIL} 196 | sed -i 's/LETSENCRYPT_EMAIL=.*/LETSENCRYPT_EMAIL="'$acmeContact'"/g' ./piler.conf 197 | fi 198 | 199 | # use Mailcow 200 | while true; do 201 | read -ep "If Use Mailcow API Options (yes/no)? / Y|N: " jn 202 | case $jn in 203 | [Yy]* ) sed -i 's/USE_MAILCOW=.*/USE_MAILCOW=true/g' ./piler.conf; break;; 204 | [Nn]* ) sed -i 's/USE_MAILCOW=.*/USE_MAILCOW=false/g' ./piler.conf; break;; 205 | * ) echo -e "${redBold} Please confirm with Y or N.${normal}";; 206 | esac 207 | done 208 | 209 | # reload config 210 | . ./piler.conf 211 | 212 | if [ "$USE_MAILCOW" = true ]; then 213 | # Mailcow API-Key 214 | read -ep "Please set your Mailcow API-Key (current: $MAILCOW_APIKEY): " apiKey 215 | apiKey=${apiKey:=$MAILCOW_APIKEY} 216 | sed -i 's/MAILCOW_APIKEY=.*/MAILCOW_APIKEY="'$apiKey'"/g' ./piler.conf 217 | 218 | # Mailcow Host Domain 219 | read -ep "Please set your Mailcow Host Domain (Enter for default: $imapServer): " mailcowHost 220 | mailcowHost=${mailcowHost:=$imapServer} 221 | sed -i 's/MAILCOW_HOST=.*/MAILCOW_HOST="'$mailcowHost'"/g' ./piler.conf 222 | fi 223 | 224 | # Import Interval Settings 225 | while true; do 226 | read -ep "If Use automatic import to 5 minutes interval (yes/no)? / Y|N (Default: no): " jn 227 | case $jn in 228 | [Yy]* ) sed -i 's/AUTO_IMPORT=.*/AUTO_IMPORT=true/g' ./piler.conf; break;; 229 | [Nn]* ) sed -i 's/AUTO_IMPORT=.*/AUTO_IMPORT=false/g' ./piler.conf; break;; 230 | * ) echo -e "${redBold} Please confirm with Y or N.${normal}";; 231 | esac 232 | done 233 | 234 | echo 235 | echo "${blue}${HLINE}" 236 | echo "All settings were saved in the piler.conf file" 237 | echo "and can be adjusted there at any time." 238 | echo "${blue}${HLINE}${normal}" 239 | echo 240 | 241 | # config done 242 | touch $installPth/.configDone 243 | 244 | elif [ -f $installPth/.configDone ]; then 245 | # Load config 246 | . ./piler.conf 247 | 248 | select name in Install-Piler Update-Piler 249 | do 250 | if [ $name = "Install-Piler" ]; then 251 | echo 252 | echo "${blue}Ready for: $name${normal}" && break 253 | echo 254 | elif [ $name = "Update-Piler" ]; then 255 | echo 256 | echo "${blue}Ready for: $name${normal}" 257 | echo 258 | 259 | for fileUpdate in update.sh README.md; do 260 | echo "${purple}${HLINE}${HLINE_SMALL}" 261 | echo "${purple}****** Download Update $fileUpdate ******" 262 | #curl -o $installPth/$fileUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/$fileUpdate 263 | wget https://raw.githubusercontent.com/simatec/piler-docker/main/$fileUpdate -O $installPth/$fileUpdate 264 | echo "${purple}${HLINE}${HLINE_SMALL}${normal}" 265 | echo 266 | done 267 | touch $installPth/.update 268 | bash $installPth/update.sh && exit 0 269 | fi 270 | done 271 | fi 272 | 273 | # uninstall Postfix 274 | while true; do 275 | read -ep "Postfix must be uninstalled prior to installation. Do you want to uninstall Postfix now? (y/n): " yn 276 | case $yn in 277 | [Yy]* ) apt purge postfix -y; break;; 278 | [Nn]* ) echo -e "${redBold} The installation process is aborted because Postfix has not been uninstalled.!! ${normal}"; exit;; 279 | * ) echo -e "${redBold} Please confirm with y or n.${normal}";; 280 | esac 281 | done 282 | 283 | # start piler install 284 | while true; do 285 | read -ep "Do you want to start the Piler installation now? / Y|N: " yn 286 | case $yn in 287 | [Yy]* ) echo -e "${greenBold}Piler install started!! ${normal}"; break;; 288 | [Nn]* ) echo -e "${redBold}Aborting the Piler installation!! ${normal}"; exit;; 289 | * ) echo -e "${redBold} Please confirm with Y or N.${normal}";; 290 | esac 291 | done 292 | 293 | ######################################################################################### 294 | 295 | # reload config 296 | . ./piler.conf 297 | 298 | if [ ! -f $installPth/.env ]; then 299 | ln -s ./piler.conf .env 300 | fi 301 | 302 | # create Network 303 | if docker network inspect pilernet > /dev/null 2>&1; then 304 | echo "Network pilernet is available" 305 | else 306 | docker network create pilernet 307 | echo "Network pilernet created" 308 | fi 309 | 310 | # Build Piler 311 | #cd $buildPth 312 | #echo "${greenBold}Start Piler-Build...${normal}" && \ 313 | #bash build.sh && \ 314 | #echo "${greenBold}Piler-Build finish${normal}" 315 | 316 | if [ -f $installPth/docker-compose.yml ]; then 317 | rm $installPth/docker-compose.yml 318 | fi 319 | 320 | if [ "$USE_LETSENCRYPT" = "yes" ]; then 321 | cp $configPth/piler-ssl.yml $installPth/docker-compose.yml 322 | else 323 | cp $configPth/piler-default.yml $installPth/docker-compose.yml 324 | fi 325 | 326 | # old docker stop 327 | cd $installPth 328 | 329 | if [ $COMPOSE_VERSION = native ]; then 330 | docker compose down 331 | else 332 | docker-compose down 333 | fi 334 | 335 | # docker start 336 | echo 337 | echo "${greenBold}${HLINE}" 338 | echo "${greenBold} start docker-compose for Piler" 339 | echo "${greenBold}${HLINE}${normal}" 340 | echo 341 | 342 | cd $installPth 343 | 344 | if [ "$USE_LETSENCRYPT" = "yes" ]; then 345 | if ! docker network ls | grep -o "nginx-proxy"; then 346 | docker network create nginx-proxy 347 | 348 | echo 349 | echo "${blue}${HLINE}" 350 | echo "${blue} docker network created" 351 | echo "${blue}${HLINE}${normal}" 352 | echo 353 | fi 354 | fi 355 | 356 | if [ $COMPOSE_VERSION = native ]; then 357 | docker compose up -d 358 | else 359 | docker-compose up -d 360 | fi 361 | 362 | 363 | echo "${blue}********* Piler started... Please wait... *********" 364 | 365 | BLA::start_loading_animation "${BLA_metro[@]}" 366 | sleep 20 367 | BLA::stop_loading_animation 368 | 369 | echo 370 | echo "${blue}${HLINE}" 371 | echo "${blue} backup the File config-site.php" 372 | echo "${blue}${HLINE}${normal}" 373 | echo 374 | 375 | if [ ! -f $etcPth/config-site.php.bak ]; then 376 | cp $etcPth/config-site.php $etcPth/config-site.php.bak 377 | else 378 | rm $etcPth/config-site.php 379 | cp $etcPth/config-site.php.bak $etcPth/config-site.php 380 | fi 381 | 382 | echo 383 | echo "${blue}${HLINE}" 384 | echo "${blue} set User settings ..." 385 | echo "${blue}${HLINE}${normal}" 386 | echo 387 | 388 | cat >> $etcPth/config-site.php <> $cronPth/piler <> $etcPth/config-site.php <> $etcPth/piler.conf <//g" "$file" 98 | 99 | if grep -q '\btlisten\b' "$file"; then 100 | sed -i 's/\btlisten\b/listen/g' "$file" 101 | fi 102 | 103 | echo "Patch manticore.conf with new entry: listen = 127.0.0.1:9307:mysql_readonly" 104 | else 105 | echo "Patch already executed. No action required" 106 | fi 107 | else 108 | echo "The file manticore.conf does not exist. The patch cannot be executed" 109 | fi 110 | fi 111 | ####################################################################################### 112 | 113 | ################################ Patch config-site-php ################################ 114 | configSite="/var/lib/docker/volumes/piler-docker_piler_etc/_data/config-site.php" 115 | etcPth="/var/lib/docker/volumes/piler-docker_piler_etc/_data" 116 | 117 | if ! grep -qF "### Begin added by Piler-Installer ###" "$configSite"; then 118 | cat >> $configSite <> $configSite < /dev/null 2>&1; then 107 | if docker compose version --short | grep "^2." > /dev/null 2>&1; then 108 | COMPOSE_VERSION=native 109 | echo -e "${purple}Found Docker Compose Plugin (native).${normal}" 110 | echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to native${normal}" 111 | sleep 2 112 | echo -e "${purple}Notice: You´ll have to update this Compose Version via your Package Manager manually!${normal}" 113 | else 114 | echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}" 115 | exit 1 116 | fi 117 | elif docker-compose > /dev/null 2>&1; then 118 | if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then 119 | if docker-compose version --short | grep "^2." > /dev/null 2>&1; then 120 | COMPOSE_VERSION=standalone 121 | echo -e "${purple}Found Docker Compose Standalone.${normal}" 122 | echo -e "${purple}Setting the DOCKER_COMPOSE_VERSION Variable to standalone${normal}" 123 | sleep 2 124 | else 125 | echo -e "${redBold}Cannot find Docker Compose with a Version Higher than 2.X.X.${normal}" 126 | exit 1 127 | fi 128 | fi 129 | 130 | else 131 | echo -e "${redBold}Cannot find Docker Compose.${normal}" 132 | exit 1 133 | fi 134 | 135 | ####################################################################################### 136 | 137 | while true; do 138 | read -ep "Do you want to perform the update?? (y/n): " yn 139 | case $yn in 140 | [Yy]* ) echo "${greenBold}********* Update started... Please wait... *********${normal}"; break;; 141 | [Nn]* ) echo -e "${redBold} The update is canceled!${normal}"; exit;; 142 | * ) echo -e "${redBold} Please confirm with y or n.${normal}";; 143 | esac 144 | done 145 | 146 | installPth=`pwd` 147 | configPth="$installPth/config" 148 | etcPth="/var/lib/docker/volumes/piler-docker_piler_etc/_data" 149 | buildPth="$installPth/build" 150 | 151 | if [ ! -f $installPth/.update ]; then 152 | echo 153 | echo "${redBold}${HLINE}" 154 | echo "${redBold} Please restart the update with installer.sh" 155 | echo "${redBold}${HLINE}${normal}" 156 | echo 157 | exit 1 158 | else 159 | rm $installPth/.update 160 | fi 161 | 162 | if [ -f $installPth/docker-compose.yml ]; then 163 | rm $installPth/docker-compose.yml 164 | fi 165 | 166 | # Download yml update 167 | echo 168 | echo "${greenBold}${HLINE}" 169 | echo "${greenBold} Download Update files for Piler" 170 | echo "${greenBold}${HLINE}${normal}" 171 | echo 172 | 173 | # Update Files 174 | for ymlUpdate in piler-default.yml piler-ssl.yml; do 175 | echo 176 | echo "${purple}${HLINE}${HLINE_SMALL}" 177 | echo "${purple}****** Download Update $ymlUpdate ******" 178 | #curl -o $configPth/$ymlUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/config/$ymlUpdate 179 | wget https://raw.githubusercontent.com/simatec/piler-docker/main/config/$ymlUpdate -O $configPth/$ymlUpdate 180 | echo "${purple}${HLINE}${HLINE_SMALL}${normal}" 181 | echo 182 | done 183 | 184 | for fileUpdate in install-piler.sh LICENSE piler.conf.example patch.sh; do 185 | echo 186 | echo "${purple}${HLINE}${HLINE_SMALL}" 187 | echo "${purple}****** Download Update $fileUpdate ******" 188 | #curl -o $installPth/$fileUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/$fileUpdate 189 | wget https://raw.githubusercontent.com/simatec/piler-docker/main/$fileUpdate -O $installPth/$fileUpdate 190 | echo "${purple}${HLINE}${HLINE_SMALL}${normal}" 191 | echo 192 | done 193 | 194 | for buildUpdate in start.sh build.sh Dockerfile build.conf; do 195 | echo 196 | echo "${purple}${HLINE}${HLINE_SMALL}" 197 | echo "${purple}****** Download Update $buildUpdate ******" 198 | #curl -o $buildPth/$buildUpdate https://raw.githubusercontent.com/simatec/piler-docker/main/build/$buildUpdate 199 | wget https://raw.githubusercontent.com/simatec/piler-docker/main/build/$buildUpdate -O $buildPth/$buildUpdate 200 | echo "${purple}${HLINE}${HLINE_SMALL}${normal}" 201 | echo 202 | done 203 | 204 | # build config load 205 | . $buildPth/build.conf 206 | 207 | # set Piler Version 208 | sed -i 's/PILER_VERSION=.*/PILER_VERSION="'$PILER_VERSION'"/g' ./piler.conf 209 | 210 | # set Maria-DB Version 211 | sed -i 's/MARIA_DB_VERSION=.*/MARIA_DB_VERSION="'$MARIA_DB_VERSION'"/g' ./piler.conf 212 | 213 | # config load 214 | . ./piler.conf 215 | 216 | if [ ! -f $installPth/.env ]; then 217 | ln -s ./piler.conf .env 218 | fi 219 | 220 | # old docker stop 221 | cd $installPth 222 | 223 | if [ $COMPOSE_VERSION = native ]; then 224 | docker compose down 225 | else 226 | docker-compose down 227 | fi 228 | 229 | # create Network 230 | if docker network inspect pilernet > /dev/null 2>&1; then 231 | echo "Network pilernet is available" 232 | else 233 | docker network create pilernet 234 | echo "Network pilernet created" 235 | fi 236 | 237 | # Backup Config 238 | if [ ! -d $installPth/backup ]; then 239 | mkdir -p $installPth/backup 240 | fi 241 | 242 | cp -rf $etcPth/* $installPth/backup/ 243 | 244 | # Added Manticore 245 | if [ ! -f $etcPth/MANTICORE ]; then 246 | touch $etcPth/MANTICORE 247 | fi 248 | 249 | # Copy docker-compose.yml 250 | if [ "$USE_LETSENCRYPT" = "yes" ]; then 251 | cp $configPth/piler-ssl.yml $installPth/docker-compose.yml 252 | else 253 | cp $configPth/piler-default.yml $installPth/docker-compose.yml 254 | fi 255 | # Check for Patches before Update 256 | bash $installPth/patch.sh 257 | BLA::start_loading_animation "${BLA_metro[@]}" 258 | sleep 5 259 | BLA::stop_loading_animation 260 | 261 | # start Update Container 262 | echo 263 | echo "${greenBold}${HLINE}" 264 | echo "${greenBold} Update Container for Piler" 265 | echo "${greenBold}${HLINE}${normal}" 266 | echo 267 | 268 | if [ "$USE_LETSENCRYPT" = "yes" ]; then 269 | if ! docker network ls | grep -o "nginx-proxy"; then 270 | docker network create nginx-proxy 271 | 272 | echo 273 | echo "${blue}${HLINE}" 274 | echo "${blue} docker network created" 275 | echo "${blue}${HLINE}${normal}" 276 | echo 277 | fi 278 | fi 279 | 280 | if [ $COMPOSE_VERSION = native ]; then 281 | docker compose up --force-recreate --build -d 282 | else 283 | docker-compose up --force-recreate --build -d 284 | fi 285 | 286 | echo 287 | echo "${greenBold}${HLINE}" 288 | echo "${greenBold} Reindex Piler" 289 | echo "${greenBold}${HLINE}${normal}" 290 | echo 291 | 292 | while true; do 293 | read -ep "Do you want to perform the Reindex?? (y/n): " yn 294 | case $yn in 295 | [Yy]* ) echo "${greenBold}********* Reindex started... Please wait... *********${normal}"; break;; 296 | [Nn]* ) echo -e "${redBold} Update without Reindex!${normal}"; finish_info;; 297 | * ) echo -e "${redBold} Please confirm with y or n.${normal}";; 298 | esac 299 | done 300 | 301 | BLA::start_loading_animation "${BLA_metro[@]}" 302 | sleep 15 303 | docker exec -u piler -w /var/tmp piler reindex -a 304 | BLA::stop_loading_animation 305 | finish_info 306 | --------------------------------------------------------------------------------