I've written a short postinst Script to create some Directories after my Application has been installed, with the Intention that the Application may create new Subdirectories of these Directories regardless of the User that will use the Application later, like Log-Files in several Subdirectories.
My Script looks like this:
#!/bin/bash
set -e
if [ ! -d "/opt/myApp/logs" ]; then
sudo mkdir /opt/myApp/logs
sudo chmod a+rwX /opt/myApp/logs
sudo setfacl -d -m u::rwX /opt/myApp/logs
sudo setfacl -d -m g::rwX /opt/myApp/logs
sudo setfacl -d -m o::rwX /opt/myApp/logs
sudo mkdir /opt/myApp/logs/srv
sudo mkdir /opt/myApp/logs/inst
fi
When I build my *.deb Package and use the Software Installer to install my App, the /opt/myApp/logs Directory gets created, but not the Subdirectories /srv and /inst.
To check out what's wrong, I normally do the following Steps:
run my postinst Script manually from within the Terminal, and all Subdirectories will be created
Uninstall my Application via the Software Installer
remove all Directories created by the postinstall Script manually
Reinstall the Application via Software Installer
This Time all Directories are created by the Script as intended.
Application works.
Try it out on a "fresh" Ubuntu Installation
start all over again: Directories won't be created the first Time the postinst Script is executed by the Software Installer on a "fresh" Linux.
Any Suggestions why the Subdirectories won't be created by the Software Installer Application when run for the first Time, but only when I execute my postinst Script manually? And afterwards also by the Software Installer with the exact same postinst Script?