Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Piwigo Plugin for TrueNAS - ready to test!

Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
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
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:

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Got to the moment when all was working perfectly, but than after another test, I got stuck on POST_INSTALL.SH. Some kind of permission problem? Basically its not working after setting chmod to +x or 0755. PIWIGO.JSON working perfectly, installing iocage, all needed packages, but than:
Code:
root@freenas:~ # iocage fetch -P /mnt/DATA/piwigo.json --keep_jail_on_failure
Plugin: Piwigo
  Official Plugin: False
  Using RELEASE: 11.3-RELEASE
  Using Branch: 12.2-RELEASE
  Post-install Artifact: https://github.com/AfroUSApl/piwigo.git
  These pkgs will be installed:
    - bash
    - git
    - ImageMagick7-nox11
    - php73
    - php73-exif
    - php73-filter
    - php73-gd
    - php73-hash
    - php73-mbstring
    - php73-mysqli
    - php73-json
    - php73-session
    - php73-zip
    - php73-zlib
    - nginx
    - mariadb105-server

Testing Host DNS response to pkg.FreeBSD.org
Testing Piwigo_1's SRV response to pkg.FreeBSD.org
Testing Piwigo_1's DNSSEC response to pkg.FreeBSD.org

Installing plugin packages:
  - bash...
  - git...
  - ImageMagick7-nox11...
  - php73...
  - php73-exif...
  - php73-filter...
  - php73-gd...
  - php73-hash...
  - php73-mbstring...
  - php73-mysqli...
  - php73-json...
  - php73-session...
  - php73-zip...
  - php73-zlib...
  - nginx...
  - mariadb105-server...

Fetching artifact...
Cloning git repository

Branch 12.2-RELEASE does not exist at https://github.com/AfroUSApl/piwigo.git!
Using "master" branch for plugin, this may not work with your RELEASE

Running post_install.sh
jexec: execvp: /root/post_install.sh: No such file or directory
Last 10 lines:
jexec: execvp: /root/post_install.sh: No such file or directory
root@freenas:~ #


This is my new 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"
}


This is clean POST_INSTALL.SH
Code:
#!/bin/sh
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"
service nginx start 2>/dev/null
service php-fpm start 2>/dev/null
service mysql-server start 2>/dev/null
pw user add -n piwigo -s /sbin/nologin -c "Piwigo"
cp /usr/local/etc/mysql/my-small.cnf /usr/local/etc/mysql/my.cnf
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
mkdir /usr/local/etc/nginx/conf.d
mkdir /usr/local/etc/php-fpm.d
fetch -o /usr/local/etc/nginx/nginx.conf https://raw.githubusercontent.com/AfroUSApl/piwigo/master/nginx.conf
fetch -o /usr/local/etc/php.ini https://raw.githubusercontent.com/AfroUSApl/piwigo/master/php.ini
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
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
USER="piwigouser"
DB="piwigodb"
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"
mysql -u root -p <<-EOF
CREATE DATABASE piwigodb CHARACTER SET utf8;
CREATE USER 'piwigouser'@'localhost' IDENTIFIED BY '${PASS}';
GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost';
FLUSH PRIVILEGES;
EOF
else
mysql -u root -p <<-EOF
CREATE DATABASE piwigodb CHARACTER SET utf8;
CREATE USER '${USER}'@'localhost' IDENTIFIED BY '${PASS}';
GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost';
FLUSH PRIVILEGES;
EOF
fi
cd /usr/local/www
git clone -b 11.x https://github.com/Piwigo/Piwigo.git
mkdir /usr/local/www/Piwigo/_data
chmod -R 777 /usr/local/Piwigo/_data
chown -R piwigo:www /usr/local/www/Piwigo
service php-fpm restart 2>/dev/null
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


This is iocage /root/ folder where after setting up new iocage I have post_install.sh
Code:
root@Piwigo-1:~ # ls -l
total 23
-rw-r--r--  2 root  wheel   957 Jul  5  2019 .cshrc
-rw-r--r--  1 root  wheel   149 Jul  5  2019 .k5login
-rw-r--r--  1 root  wheel   395 Jul  5  2019 .login
-rw-r--r--  2 root  wheel   474 Jul  5  2019 .profile
-rwxr-xr-x  1 root  wheel  2391 Feb 18 22:40 post_install.sh


Running post_install.sh from SSH terminal I have this:

Code:
root@Piwigo-1:~ # sh post_install.sh
nginx_enable:  -> YES
mysql_enable:  -> YES
php_fpm_enable:  -> YES
: Operation not supportedreate /dev/null
: Operation not supportedreate /dev/null
: Operation not supportedreate /dev/null
cp: /usr/local/etc/mysql/my-small.cnf: No such file or directory
: Not Founds://raw.githubusercontent.com/AfroUSApl/piwigo/master/nginx.conf
: Not Founds://raw.githubusercontent.com/AfroUSApl/piwigo/master/php.ini
: Not Founds://raw.githubusercontent.com/AfroUSApl/piwigo/master/nginx/conf.d/piwigo.example.com.conf
: Not Founds://raw.githubusercontent.com/AfroUSApl/piwigo/master/php-fpm.d/piwigo.example.com.conf
: Not Founds://raw.githubusercontent.com/AfroUSApl/piwigo/master/php-fpm.d/www.conf
cat: /root/dbpassword: No such file or directory
post_install.sh: 56: Syntax error: end of file unexpected (expecting "then")

 
Last edited:

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
But than after coping post_install.sh from PIWIGO iocage main folder -> PIWIGO/PLUGIN/post_install.sh to PIWIGO/ROOT/ROOT/post_install.sh, adding chmod +x /root/post_install.sh, than running:
/bin/sh /root/post-install.sh
script is working fine !!
Where is my mistake?

Code:
root@Piwigo-1:/ # chmod +x /root/post_install.sh
root@Piwigo-1:/ # /bin/sh /root/post_install.sh
 -> YESnable: YES
 -> YESnable: YES
 -> YES_enable: YES
Performing sanity check on nginx configuration:
Starting nginx.
Performing sanity check on php-fpm configuration:
Starting php_fpm.
Installing MariaDB/MySQL system tables in '/var/db/mysql' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr/local' ; /usr/local/bin/mysqld_safe --datadir='/var/db/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/local/mysql-test' ; perl mysql-test-run.pl

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

Starting mysql.
pw: login name `piwigo' already exists
cp: /usr/local/etc/mysql/my-small.cnf: No such file or directory
mkdir: /usr/local/etc/php-fpm.d: File exists
/usr/local/etc/nginx/nginx.conf                        487  B 2882 kBps    00s
/usr/local/etc/php.ini                                  69 kB 4332 kBps    00s
/usr/local/etc/nginx/conf.d/piwigo.example.com        1640  B 8803 kBps    00s
/usr/local/etc/php-fpm.d/piwigo.example.com.co         246  B 1356 kBps    00s
/usr/local/etc/php-fpm.d/www.conf                       19 kB 5366 kBps    01s
Enter password:
Cloning into 'Piwigo'...
remote: Enumerating objects: 137, done.
remote: Counting objects: 100% (137/137), done.
remote: Compressing objects: 100% (104/104), done.
remote: Total 109237 (delta 78), reused 80 (delta 33), pack-reused 109100
Receiving objects: 100% (109237/109237), 56.71 MiB | 7.75 MiB/s, done.
Resolving deltas: 100% (83252/83252), done.
chmod: /usr/local/Piwigo/_data: No such file or directory
Performing sanity check on php-fpm configuration:
Stopping php_fpm.
Waiting for PIDS: 51352.
Performing sanity check on php-fpm configuration:
Starting php_fpm.
Performing sanity check on nginx configuration:
root@Piwigo-1:/ #
 

Jurgen Segaert

Senior Member
Joined
Jul 10, 2016
Messages
435
The line-endings in the post_install.sh look odd. Did you create this with a Windows Editor? Look at it in FreeNAS/FreeBSD with ee post_install.sh and you'll see the ^M everywhere.

Code:
#!/bin/sh^M
sysrc -f /etc/rc.conf nginx_enable="YES"^M
sysrc -f /etc/rc.conf mysql_enable="YES"^M
sysrc -f /etc/rc.conf php_fpm_enable="YES"^M
service nginx start 2>/dev/null^M
service php-fpm start 2>/dev/null^M
service mysql-server start 2>/dev/null^M
pw user add -n piwigo -s /sbin/nologin -c "Piwigo"^M
cp /usr/local/etc/mysql/my-small.cnf /usr/local/etc/mysql/my.cnf^M
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini^M
#(etc...)

You'll need to remove these funky line endings. :smile:

Here is some additional feedback:
  • Use 11.4-RELEASE, as 11.3-RELEASE is already EOL - this is OK even on FreeNAS 11.3
  • You can create a special directory overlay in your repo. All files and folders in there will be copied to the corresponding directory in your plugin-jail after the pkgs are installed, e.g. /overlay/usr/local/etc/nginx/nginx.conf. This will let you do away with all these fetch commands.
 

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Jurgen, thank you so much for taking a time to look into this!
I have edited this on my phone, in my new file manager and its text editor. This must be the issue. I will need to read your additional directions and learn how to use overlay ;)

BTW I learn this from your post here -> Create an unofficial iocage plugin
 
Last edited:

Jurgen Segaert

Senior Member
Joined
Jul 10, 2016
Messages
435

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Hi,
Another update, part 2 ;)
I did manage to update my files following your advice. I'm using 12.2-RELEASE, additional files in /overlay folder as there is a lot of code to replace, hence easy to swap file.
Process passed without errors. One thing needs to be changed while installing Piwigo on first setup page, is Host: from localhost to 127.0.0.1.

Plugin is ready for testing :)

piwigo.json
Code:
{
    "name": "Piwigo",
    "plugin_schema": "2",
    "release": "12.2-RELEASE",
    "artifact": "https://github.com/AfroUSApl/iocage-plugin-piwigo.git",
    "official": false,
    "properties": {
        "vnet": 1,
        "dhcp": 1
    },
    "pkgs": [
        "ImageMagick7-nox11",
        "git",
        "nginx",
        "mariadb105-server",
        "php73",
        "php73-exif",
        "php73-filter",
        "php73-gd",
        "php73-hash",
        "php73-mbstring",
        "php73-mysqli",
        "php73-json",
        "php73-session",
        "php73-zip",
        "php73-zlib"
    ],
    "packagesite": "http://pkg.FreeBSD.org/${ABI}/latest",
    "fingerprints": {
        "iocage-plugins": [
            {
                "function": "sha256",
                "fingerprint": "b0170035af3acc5f3f3ae1859dc717101b4e6c1d0a794ad554928ca0cbb2f438"
            }
        ]
    },
    "revision": "0"
}


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

# Create user 'piwigo'
pw user add -n piwigo -s /sbin/nologin -c "Piwigo"
# 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

# Modify settings in php.ini for Piwigo best performance
sed -i '' 's/.*max_execution_time = .*/max_execution_time = 300/' /usr/local/etc/php.ini
sed -i '' 's/.*max_input_time = .*/max_input_time = 300/' /usr/local/etc/php.ini
sed -i '' 's/.*post_max_size = .*/post_max_size = 100M/' /usr/local/etc/php.ini
sed -i '' 's/.*upload_max_filesize = .*/upload_max_filesize=100M/' /usr/local/etc/php.ini
# recommended value of 512MB for php memory limit (avoid warning)
sed -i '' 's/.*memory_limit = .*/memory_limit = 512M/' /usr/local/etc/php.ini
sed -i '' 's/.*;date.timezone =.*/date.timezone = "Europe\/London"/' /usr/local/etc/php.ini

# 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
# Editing WWW config file - www.conf
grep -qxF 'request_terminate_timeout = 300' /usr/local/etc/php-fpm.d/www.conf || echo 'request_terminate_timeout = 300' >> /usr/local/etc/php-fpm.d/www.conf
# Editing PHP-FPM config file - php-fpm.conf
grep -qxF 'include=/usr/local/etc/php-fpm.d/*.conf' /usr/local/etc/php-fpm.conf || echo 'include=/usr/local/etc/php-fpm.d/*.conf' >> /usr/local/etc/php-fpm.conf

# Create user and database for Piwigo with unique password
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`
echo "Database User: $USER"
echo "Database Password: $PASS"
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 db
echo "ROOT Temp Password: $TMPPW"
mysql -u root -p"${TMPPW}" --connect-expired-password <<-EOF
ALTER USER 'root'@'localhost' IDENTIFIED BY '${PASS}';
CREATE DATABASE ${DB} CHARACTER SET utf8;
CREATE USER '${USER}'@'localhost' IDENTIFIED BY '${PASS}';
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
ALTER USER 'root'@'localhost' IDENTIFIED BY '$TMPPW';
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 DATABASE ${DB} CHARACTER SET utf8;
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

# Download Piwigo version 11.x from GitHub
cd /usr/local/www
git clone -b 11.x https://github.com/Piwigo/Piwigo.git
# Create Piwigo data directory with permission
mkdir /usr/local/www/Piwigo/_data
chmod -R 777 /usr/local/www/Piwigo/_data
# Change the ownership of the whole Piwigo directory
chown -R piwigo:www /usr/local/www/Piwigo

#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

# Add plugin detals to info file available in TrueNAS Plugin Additional Info
echo "Database User: $USER" > /root/PLUGIN_INFO
echo "Database Password: $PASS" >> /root/PLUGIN_INFO
echo "Database Name: $DB" >> /root/PLUGIN_INFO
 
Last edited:

Jurgen Segaert

Senior Member
Joined
Jul 10, 2016
Messages
435
1613796842975.png

Woohoo, it worked!

The scripts look good. I also had to change the host to 127.0.0.1, so maybe add a line for Host: 127.0.0.1 to the post-installation notes /root/PLUGIN_INFO so all those initial settings are in one place.

I would suggest to create a "12.2-RELEASE" branch; this is just to remove one of the warnings during installation. It tries to match to the FreeBSD version of FreeNAS/TrueNAS, and reverts to the "master" branch otherwise.

Looks you already submitted it to the https://github.com/ix-plugin-hub/iocage-plugin-index/ repo. Nice!
 
Last edited:

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Great, happy it worked.
This host issue must be inside Piwigo install.php, I'm not sure if I should mess with code of Piwigo.
I will just add a line at the end of post_install.sh
echo "Host: 127.0.0.1" > /root/PLUGIN_INFO

What about if someone will be on the older version of TrueNAS or FreeNAS? How this script will behave than?
 

Jurgen Segaert

Senior Member
Joined
Jul 10, 2016
Messages
435
Initially, your plugin will be committed in the "master" branch of the community plugin repo at the https://github.com/ix-plugin-hub/iocage-plugin-index/ and periodically they sync "master" with the branch that corresponds with the current version of FreeNAS/TrueNAS. Currently that's the "12.2-RELEASE" branch. At that time, your plugin will show up in the TrueNAS UI.

The older versions, e.g. FreeNAS 11.3, check against the "11.3-RELEASE" branch. If you want the plugin to show in that FreeNAS version, you would need to create a separate pull request against the 11.3-RELEASE branch. In that case, be sure to change the release in the manifest json to 11.4-RELEASE.
 

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Hello,
Thank you all for helping with fixing all issues with this plugind for iocage. Seems like all was approved and plugin is live.

Now I was checking this under my plugins page in TrueNAS, but its still not showing up? How long this usualy takes to refresh the index?
 

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Patience, young grasshopper! As per my earlier post, it will only show when it gets merged in the "12.2-RELEASE" branch.
Thank you :D
Hope I did not clogg our repo with my costant refreshing of index :)
 

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Piwigo is officially available as a community plugin in TrueNAS !!

 

joyoftech

Junior Member
Joined
Feb 25, 2021
Messages
16
Hi @AfroUSA,
Many thanks for the plugin, installed it just now and worked like a charm (had to input 127.0.0.1 in place of localhost though when connecting for the first time).
I'm wondering which mount points to set up so as not to loose either the database or the uploaded photos (so we're most likely looking at two mount points; am I missing something?) if I ever have to kill the jail.
Do you know their paths, or have any recommendation in that regard?
 

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
I'm wondering which mount points to set up so as not to loose either the database or the uploaded photos (so we're most likely looking at two mount points; am I missing something?) if I ever have to kill the jail.
Do you know their paths, or have any recommendation in that regard?
Hi, as for paths to photos, I have this set like this:
my photos are in my first pool - DATA, in the main folder mnt/DATA/Photos, than in separate subfolders, like - my_wife_iphone, my _phone, old_photos.
Than all jails are in my second pool - WebDATA, so my mounting points are from pool 1 to jail with Piwigo/Galleries and equivalent subfolders - my_wife_iphone, my_phone and old_photos. Piwigo can see all photos in pool 1 - DATA, in folder Photos and all subfolders.
You don't need to save DB from Piwigo, as after killing and setting new jail with Piwigo, you will update DB again from your mounting point. Photos are safe in my first pool.
 

joyoftech

Junior Member
Joined
Feb 25, 2021
Messages
16
So my mounting points are from pool 1 to jail with Piwigo/Galleries and equivalent subfolders
Ok great, I'll take a look.
You don't need to save DB from Piwigo, as after killing and setting new jail with Piwigo, you will update DB again from your mounting point. Photos are safe in my first pool.
Well, in that case, wouldn't you be losing Piwigo's configuration (or is that in a file somewhere?) meaning: users, permissions, plugins, ... And everything it stores (my first guess: ratings, comments, ...).
 

AfroUSA

Junior Member
Joined
Mar 27, 2017
Messages
20
Ok great, I'll take a look.

Well, in that case, wouldn't you be losing Piwigo's configuration (or is that in a file somewhere?) meaning: users, permissions, plugins, ... And everything it stores (my first guess: ratings, comments, ...).
All this is stored in db. In case you would like to backup this info, you will need to make a copy of piwigo db. You can use phpmyadmin to have GUI or use command line.
 
Last edited:
Top