Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SleepingPanda/cc2f7fea37000f8eec2c5e92cf156d39 to your computer and use it in GitHub Desktop.
Save SleepingPanda/cc2f7fea37000f8eec2c5e92cf156d39 to your computer and use it in GitHub Desktop.
TrueNAS Jail Setup Guide for Komga!
# Create a pkg.json file containing everything your jail needs to install and run Komga.
echo '{"pkgs":["openjdk11-jre","nano","ca_root_nss","yarn"]}' > /tmp/pkg.json
# Using that file we just made, create the jail with IOCAGE. Replace <KOMGA> with the IP you want the Komga server to have on your network and <ROUTER> with the address of your network's router.
iocage create -n "komga" -p /tmp/pkg.json -r 12.2-RELEASE ip4_addr="vnet0|<KOMGA>/24" defaultrouter="<ROUTER>" vnet="on" allow_raw_sockets="1" boot="on"
# We can now safely delete that file we created earlier.
rm /tmp/pkg.json
# Make a config directory to store Komga, its config files, the database and logs.
iocage exec komga mkdir -p /config/komga
# Make the comics directory where Komga will find your comics.
iocage exec komga mkdir -p /comics
# Link the config directory we just made to a safe location outside of the jail in case you want to destroy and remake the jail later without losing your database and logs. Make sure to replace <STORAGE> with a location you're comfortable with.
iocage fstab -a komga /mnt/<STORAGE>/komga /config nullfs rw 0 0
# Link the comics directory we made earlier to the comics directory stored on your TrueNAS server so Komga can read and write them. If you only want Komga to read your files, but not write to them, you can change "rw" to "ro".
iocage fstab -a komga /mnt/<COMICS_DIR> /comics nullfs rw 0 0
# Next we must stop the jail, set its mounting options for java 11 to work properly and restart the jail.
iocage stop komga
iocage set mount_fdescfs=1 komga
iocage set mount_procfs=1 komga
iocage start komga
# Download Komga to the jail and make it executable.
iocage exec komga fetch https://github.com/gotson/komga/releases/download/v0.106.1/komga-0.106.1.jar -o /config/komga/komga-latest.jar
iocage exec komga chmod u+x /config/komga/komga-latest.jar
# Next we install PM2 and tell it to startup with the jail automatically.
iocage exec komga yarn global add pm2
iocage exec komga pm2 startup
# Now we create both the application.yml file Komga requires and the ecosystem.config.js file PM2 requires:
iocage exec komga nano
# Paste the below into nano after you've modified the values as needed according to the website's documentation here https://komga.org/installation/configuration.html and save the file to /config/komga/application.yml:
komga:
remember-me:
key: somerandomkey1245
validity: 2592000
database:
file: /config/komga/database.sqlite
server:
port: 80
logging:
file:
name: /config/komga/komga.log
max-history: 5
# And paste the below into nano and save the file as /config/komga/ecosystem.config.js:
module.exports = {
"apps":[
{
"name":"Komga",
"script":"java",
"cwd":"/config/komga",
"args":[
"-jar",
"/config/komga/komga-latest.jar"
],
"watch":[
"/config/komga/komga-latest.jar"
],
"node_args":[],
"log_date_format":"YYYY-MM-DD HH:mm Z",
"exec_interpreter":"none",
"exec_mode":"fork"
}
]
}
# Run Komga and save your settings:
iocage exec komga pm2 start /config/komga/ecosystem.config.js
iocage exec komga pm2 save
# If you want to see the status of the Komga server you can use this command:
iocage exec komga pm2 status
# Or to restart Komga, use:
iocage exec komga pm2 restart Komga
# You can find a whole list of commands and more documentation on PM2's configuration file here https://pm2.keymetrics.io/docs/usage/application-declaration/.
# Komga is now accessible from the LAN IP you used to make the jail and the port number you used in application.yml. Enjoy!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment