FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
02-19-2024 03:46 PM - edited 02-19-2024 03:47 PM
Description: I have developed an snap app that includes both install and remove hooks. The install hook successfully creates a directory during installation, while the remove hook is supposed to remove this directory upon uninstallation. However, I'm encountering a problem where the remove hook fails to remove the directory due to insufficient permissions.
Here is how my working install script looks:
# Copies configuration file 'app.conf' into current 'Active Configuration'
APP_DIR=$SNAP_COMMON/solutions/activeConfiguration/my-app/app
if [ ! -d "$APP_DIR" ]; then
echo "Creating directory at $APP_DIR"
mkdir -p $APP_DIR
fi
cp $SNAP/config/app.conf $APP_DIR/app.conf
chmod 666 $APP_DIR/app.conf
Here is my remove script (that doesn't work):
# Remove the active configuration directory APP_DIR=$SNAP_COMMON/solutions/activeConfiguration/my-app if [ -d "$APP_DIR" ]; then echo "Removing active configuration directory from $APP_DIR" if rm -rf "$APP_DIR"; then echo "Directory removed successfully" else echo "Failed to remove directory" exit 1 fi else echo "Active configuration directory does not exist at $APP_DIR" fi
The final output from the remove script is :
snap.d service: /snap/my-app/x1/meta/hooks/remove: 19: Permission denied
Failed to remove directory
Additional info:
- Build environment: Ubuntu 20.04
- Snap base: core20
- CtrlX Core Virtual version: 1.20.9
- CtrlX Works version: 1.20.5
How do I solve this issue this issue, why the $APP_DIR directory cannot be removed?
Solved! Go to Solution.
02-19-2024 04:01 PM - edited 02-19-2024 04:03 PM
Hello @CtrlXplorer ,
Are you also using the solutions content interface? I'm surprised you are even able to create the directory on your install hook. This is not the intended process and is also probably why you are unable to remove the directory in your uninstall hook. As this directory is outside of your snap, you will not have permissions to modify it. Snaps run in a confined sandboxed environment and are designed to only allow external interaction through plugs and slots.
See the SDK documentation on Persisting Configurations for information on working with the solutions content interface.
02-20-2024 10:17 AM
Hello @Sgilk,
Thanks for your detailed insights and explanations! I noticed that I already had the solutions content interface, but the remove hook was missing the plug towards the active-solution. My remove hook now has all the neccesary permissions to remove my app directory. I simply added the higlighted code below:
Have a nice day!