Hi all,
Today I had a moment and started to write my Piwigo plugin for TrueNAS based on Unofficial iocage Plugin manual
I have new file piwigo.json and post_install.sh, but before I can finish this, please may I ask you to take a look and check if I'm doing all in proper way?
1. piwigo.json
2. post_install.sh:
3. Is there any other way to modify/edit files I'm trying to replace in post_install.sh with "FETCH -O" ?
4. I'm having a problem with setting up mysql database, with user and password.
Today I had a moment and started to write my Piwigo plugin for TrueNAS based on Unofficial iocage Plugin manual
I have new file piwigo.json and post_install.sh, but before I can finish this, please may I ask you to take a look and check if I'm doing all in proper way?
1. piwigo.json
Code:
{ "name": "Piwigo", "plugin_schema": "2", "release": "11.3-RELEASE", "artifact": "https://github.com/AfroUSApl/piwigo.git", "official": false, "properties": { "vnet": 1, "dhcp": 1 }, "pkgs": [ "ImageMagick7-nox11", "git", "php73", "php73-exif", "php73-filter", "php73-gd", "php73-hash", "php73-mbstring", "php73-mysqli", "php73-json", "php73-session", "php73-zip", "php73-zlib", "nginx", "mariadb105-server" ], "packagesite": "http://pkg.FreeBSD.org/${ABI}/latest", "fingerprints": { "iocage-plugins": [ { "function": "sha256", "fingerprint": "b0170035af3acc5f3f3ae1859dc717101b4e6c1d0a794ad554928ca0cbb2f438" } ] }, "revision": "0" }
2. post_install.sh:
Code:
#!/bin/sh # Enable the service sysrc -f /etc/rc.conf nginx_enable="YES" sysrc -f /etc/rc.conf mysql_enable="YES" sysrc -f /etc/rc.conf php_fpm_enable="YES" # Start the service service nginx start 2>/dev/null service php-fpm start 2>/dev/null service mysql-server start 2>/dev/null #Copy a base MySQL configuration to use cp /usr/local/etc/mysql/my-small.cnf /usr/local/etc/mysql/my.cnf # Configure the default PHP settings cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini # Create user 'piwigo' pw user add -n piwigo -s /sbin/nologin -c "Piwigo" # Create a configuration directory to make managing individual server blocks easier mkdir /usr/local/etc/nginx/conf.d mkdir /usr/local/etc/php-fpm.d #https://docs.nextcloud.com/server/13/admin_manual/installation/installation_wizard.html do not use the same name for user and db USER="piwigouser" DB="piwigodb" # Save the config values echo "$DB" > /root/dbname echo "$USER" > /root/dbuser export LC_ALL=C cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1 > /root/dbpassword PASS=`cat /root/dbpassword` if [ -e "/root/.mysql_secret" ] ; then # Mysql > 57 sets a default PW on root TMPPW=$(cat /root/.mysql_secret | grep -v "^#") echo "SQL Temp Password: $TMPPW" # Configure mysql mysql -u root -p"${TMPPW}" --connect-expired-password <<-EOF ALTER USER 'root'@'localhost' IDENTIFIED BY '${PASS}'; CREATE USER '${USER}'@'localhost' IDENTIFIED BY '${PASS}'; GRANT ALL PRIVILEGES ON *.* TO '${USER}'@'localhost' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost'; FLUSH PRIVILEGES; EOF # Make the default log directory mkdir /var/log/zm chown www:www /var/log/zm else # Mysql <= 56 does not # Configure mysql mysql -u root <<-EOF UPDATE mysql.user SET Password=PASSWORD('${PASS}') WHERE User='root'; DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.db WHERE Db='test' OR Db='test_%'; CREATE USER '${USER}'@'localhost' IDENTIFIED BY '${PASS}'; GRANT ALL PRIVILEGES ON *.* TO '${USER}'@'localhost' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost'; FLUSH PRIVILEGES; EOF fi # Downloading modified main nginx config file fetch -o /usr/local/etc/nginx/nginx.conf https://raw.githubusercontent.com/AfroUSApl/piwigo/master/nginx.conf # Download modified php config file fetch -o /usr/local/etc/php.ini https://raw.githubusercontent.com/AfroUSApl/piwigo/master/php.ini # Download Piwigo version 11.x from GitHub cd /usr/local/www git clone -b 11.x https://github.com/Piwigo/Piwigo.git mkdir /usr/local/www/Piwigo/_data # Change the ownership of the piwigo directory chown -R piwigo:www /usr/local/www/Piwigo # Create an piwigo.example.com server block config file fetch -o /usr/local/etc/nginx/conf.d/piwigo.example.com.conf https://raw.githubusercontent.com/AfroUSApl/piwigo/master/nginx/conf.d/piwigo.example.com.conf # Create the piwigo php-fpm pool config file and WWW config file fetch -o /usr/local/etc/php-fpm.d/piwigo.example.com.conf https://raw.githubusercontent.com/AfroUSApl/piwigo/master/php-fpm.d/piwigo.example.com.conf fetch -o /usr/local/etc/php-fpm.d/www.conf https://raw.githubusercontent.com/AfroUSApl/piwigo/master/php-fpm.d/www.conf #restart the services to make sure we have pick up the new permission service php-fpm restart 2>/dev/null #nginx restarts to fast while php is not fully started yet sleep 5 service nginx restart 2>/dev/null echo "Database Name: $DB" > /root/PLUGIN_INFO echo "Database User: $USER" >> /root/PLUGIN_INFO echo "Database Password: $PASS" >> /root/PLUGIN_INFO
3. Is there any other way to modify/edit files I'm trying to replace in post_install.sh with "FETCH -O" ?
4. I'm having a problem with setting up mysql database, with user and password.
Last edited: