diff --git a/.gitignore b/.gitignore index 36c4259..892edd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ build_run.sh -publish.sh \ No newline at end of file +publish.sh +deb_pack.txt +build.sh +.Dockerfile.swp +.gitignore +publish.txt diff --git a/Dockerfile b/Dockerfile_AMD64 similarity index 96% rename from Dockerfile rename to Dockerfile_AMD64 index c06b80b..8a00ae9 100644 --- a/Dockerfile +++ b/Dockerfile_AMD64 @@ -74,7 +74,7 @@ RUN adduser www-data video RUN mkdir /config -COPY zoneminder_1.36.25~20220831.9-bullseye_arm64.deb / +COPY zoneminder_1.36.33~20230228.55-bullseye_amd64.deb / COPY entrypoint.sh / RUN chmod +x /entrypoint.sh diff --git a/Dockerfile_ARM64 b/Dockerfile_ARM64 new file mode 100644 index 0000000..6bf51b8 --- /dev/null +++ b/Dockerfile_ARM64 @@ -0,0 +1,87 @@ +FROM debian:bullseye-slim + +ENV TZ Etc/UTC +ENV FQDN localhost +ENV SELFSIGNED 0 + +RUN apt-get update + +RUN apt-get install -y \ +apache2 \ +mariadb-server \ +php \ +libapache2-mod-php \ +php-mysql + +RUN apt-get install -y \ +libavcodec58 \ +libavdevice58 \ +libavformat58 \ +libavutil56 \ +libcurl3-gnutls \ +libjpeg62-turbo \ +libswresample3 \ +libswscale5 \ +sudo \ +javascript-common \ +ffmpeg \ +libcurl4-gnutls-dev \ +libdatetime-perl \ +libdate-manip-perl \ +libmime-lite-perl \ +libmime-tools-perl \ +libdbd-mysql-perl \ +libphp-serialization-perl \ +libnet-sftp-foreign-perl \ +libarchive-zip-perl \ +libdevice-serialport-perl \ +libimage-info-perl \ +libjson-maybexs-perl \ +libsys-mmap-perl \ +liburi-encode-perl \ +libwww-perl \ +libdata-dump-perl \ +libclass-std-fast-perl \ +libsoap-wsdl-perl \ +libio-socket-multicast-perl \ +libsys-cpu-perl \ +libsys-meminfo-perl \ +libdata-uuid-perl \ +libnumber-bytes-human-perl \ +libfile-slurp-perl \ +php-gd \ +php-apcu \ +php-intl \ +policykit-1 \ +rsyslog \ +zip \ +libcrypt-eksblowfish-perl \ +libdata-entropy-perl \ +libvncclient1 \ +libjwt-gnutls0 \ +libgsoap-2.8.104 \ +tzdata + +RUN apt-get remove -y \ +exim4* \ +&& apt autoremove -y + +RUN apt-get install -y \ +msmtp \ +msmtp-mta + +RUN adduser www-data video + +RUN mkdir /config + +COPY zoneminder_1.36.33~20230228.55-bullseye_arm64.deb / + +COPY entrypoint.sh / +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + +VOLUME /config +VOLUME /var/cache/zoneminder +VOLUME /sslcert + +EXPOSE 443/tcp diff --git a/entrypoint.sh b/entrypoint_AMD64.sh similarity index 97% rename from entrypoint.sh rename to entrypoint_AMD64.sh index 5fcbf19..747a8ae 100644 --- a/entrypoint.sh +++ b/entrypoint_AMD64.sh @@ -9,10 +9,10 @@ dpkg-reconfigure --frontend noninteractive tzdata #install from package echo "Check ZoneMinder version" -RESULT=$(dpkg -l | grep '^ii' | grep zoneminder |grep 1.36.25) +RESULT=$(dpkg -l | grep '^ii' | grep zoneminder |grep 1.36.33) if [ "$RESULT" == "" ]; then echo "Installing new version" - dpkg -i /zoneminder_1.36.25~20220831.9-bullseye_arm64.deb + dpkg -i /zoneminder_1.36.33~20230228.55-bullseye_amd64.deb a2enmod ssl \ && a2enmod rewrite \ && a2enmod headers \ diff --git a/entrypoint_ARM64.sh b/entrypoint_ARM64.sh new file mode 100644 index 0000000..abe1681 --- /dev/null +++ b/entrypoint_ARM64.sh @@ -0,0 +1,175 @@ +#!/usr/bin/env bash + +trap stop SIGTERM SIGINT SIGQUIT SIGHUP ERR + +start(){ + +ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +dpkg-reconfigure --frontend noninteractive tzdata + +#install from package +echo "Check ZoneMinder version" +RESULT=$(dpkg -l | grep '^ii' | grep zoneminder |grep 1.36.33) +if [ "$RESULT" == "" ]; then + echo "Installing new version" + dpkg -i /zoneminder_1.36.33~20230228.55-bullseye_arm64.deb + a2enmod ssl \ + && a2enmod rewrite \ + && a2enmod headers \ + && a2enmod expires \ + && a2enconf zoneminder \ + && a2ensite default-ssl.conf +else + echo "Already up to date" +fi + +echo "Configuring MariaDBPath" +if [ ! -d /config/mysql ]; then + mkdir -p /config/mysql + rsync -a -v -q --ignore-existing /var/lib/mysql/ /config/mysql/ + echo "MariaDBPath configuration done" +else + echo "MariaDBPath already configured" +fi +sed -i -e 's,/var/lib/mysql,/config/mysql,g' /etc/mysql/mariadb.conf.d/50-server.cnf +echo 'innodb_file_per_table = ON' >> /etc/mysql/mariadb.conf.d/50-server.cnf +echo 'innodb_buffer_pool_size = 256M' >> /etc/mysql/mariadb.conf.d/50-server.cnf +echo 'innodb_log_file_size = 32M' >> /etc/mysql/mariadb.conf.d/50-server.cnf + +echo "Check MariaDB config" +/etc/init.d/mariadb start +while ! mysqladmin ping --silent; do + echo "Waiting mysql startup..." + sleep 3 +done + +RESULT=$(mysqlshow --user=zmuser --password=zmpass zm| grep -v Wildcard | grep -o Tables) +if [ "$RESULT" != "Tables" ]; then + +#configure mysql +echo "USE mysql;" > timezones.sql && mysql_tzinfo_to_sql /usr/share/zoneinfo >> timezones.sql +mysql -u root < timezones.sql +rm timezones.sql +mysql -u root < /usr/share/zoneminder/db/zm_create.sql +mysql -u root -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';" +mysqladmin -u root reload + +#secure mysql +secret=$(openssl rand -base64 14) +mysql_secure_installation <> /etc/mysql/my.cnf +# /etc/init.d/mysql restart +# while ! mysqladmin ping --silent; do +# echo "Waiting mysql restart..." +# sleep 3 +# done +#fi + +RESULT=$(cat /etc/php/*/apache2/php.ini| grep "date.timezone =") +if [ "$RESULT" = ";date.timezone =" ]; then + echo "Set Php timezone" + printf "date.timezone = $(cat /etc/timezone)" >> /etc/php/*/apache2/php.ini +fi + +echo "Checking MSMTP configuration" +if [ ! -f /config/msmtprc ]; then +printf "defaults +auth on +tls on +tls_trust_file /etc/ssl/certs/ca-certificates.crt +logfile ~/.msmtp.log +account gmail +host smtp.gmail.com +port 587 +from username@gmail.com +user username +password password +account default : gmail +" > /config/msmtprc +fi + +if [ ! -f /etc/msmtprc ]; then + ln -s /config/msmtprc /etc/msmtprc +fi + +if [ "$SELFSIGNED" = "0" ]; then + echo "Linking to SWAG" + sed -i -e 's,/etc/ssl/certs/ssl-cert-snakeoil.pem,/sslcert/live/'$FQDN'/cert.pem,g' /etc/apache2/sites-available/default-ssl.conf + sed -i -e 's,/etc/ssl/private/ssl-cert-snakeoil.key,/sslcert/live/'$FQDN'/privkey.pem,g' /etc/apache2/sites-available/default-ssl.conf +fi + +RESULT=$(cat /etc/apache2/apache2.conf| grep ServerName) +if [ "$RESULT" = "" ]; then + echo "Set ServerName" + echo "ServerName "$FQDN >> /etc/apache2/apache2.conf +fi + +echo "Setting /var/cache subfolders" +mkdir -p /var/cache/zoneminder/cache && chown www-data:www-data /var/cache/zoneminder/cache +mkdir -p /var/cache/zoneminder/events && chown www-data:www-data /var/cache/zoneminder/events +mkdir -p /var/cache/zoneminder/images && chown www-data:www-data /var/cache/zoneminder/images +mkdir -p /var/cache/zoneminder/temp && chown www-data:www-data /var/cache/zoneminder/temp + +echo "Starting" +#start +/etc/init.d/apache2 start +/usr/bin/zmpkg.pl start + +RESULT=$(tail -n2 /var/log/zm/zmpkg.log |grep "Version mismatch") +if [ "$RESULT" != "" ]; then + echo "WARNING: DB version mismatch found!" + echo "auto align.." + /usr/bin/zmpkg.pl stop + /usr/bin/zmupdate.pl -nointeractive + /usr/bin/zmupdate.pl -f + /usr/bin/zmpkg.pl start + echo "done" +fi + +mysql -e "update zm.Config set Value = '$TZ' where Name = 'ZM_TIMEZONE';" + +tail -f /var/log/apache2/error.log & wait ${!} + +} + +stop(){ + +echo "Shutdown requested" +kill ${!}; + +echo "Stopping apache" +/etc/init.d/apache2 stop +echo "Stopping zoneminder" +/usr/bin/zmpkg.pl stop +echo "Stopping mariadb" +/etc/init.d/mariadb stop + +echo "Shutdown completed" +exit +} + +start diff --git a/zoneminder_1.36.25~20220831.9-bullseye_arm64.deb b/zoneminder_1.36.25~20220831.9-bullseye_arm64.deb deleted file mode 100644 index f8a2cbd..0000000 Binary files a/zoneminder_1.36.25~20220831.9-bullseye_arm64.deb and /dev/null differ diff --git a/zoneminder_1.36.33~20230228.55-bullseye_amd64.deb b/zoneminder_1.36.33~20230228.55-bullseye_amd64.deb new file mode 100644 index 0000000..4bd2495 Binary files /dev/null and b/zoneminder_1.36.33~20230228.55-bullseye_amd64.deb differ diff --git a/zoneminder_1.36.33~20230228.55-bullseye_arm64.deb b/zoneminder_1.36.33~20230228.55-bullseye_arm64.deb new file mode 100644 index 0000000..19e880b Binary files /dev/null and b/zoneminder_1.36.33~20230228.55-bullseye_arm64.deb differ