Created
November 20, 2025 07:01
-
-
Save fredldotme/696ab1e22bec4ed296caee471aa89a87 to your computer and use it in GitHub Desktop.
Encrypt Ubuntu Touch apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| ORIG_DIR=/userdata/system-data/opt/click.ubuntu.com | |
| BAK_DIR=${ORIG_DIR}-bak | |
| TMP_DIR=${ORIG_DIR}-new | |
| function error_out { | |
| echo "$1" | |
| exit 1 | |
| } | |
| [ "$EUID" != "0" ] && error_out "Please run this script as root. Exiting." | |
| [ ! -e /etc/fscrypt.conf ] && error_out "This system doesn't have fscrypt configured, exiting." | |
| grep policy_version /etc/fscrypt.conf | grep -q 1 && error_out "This system doesn't support policy_version 2, exiting." | |
| fscrypt status /home/phablet | grep -q "is not encrypted" && error_out "Please set up encryption in system-settings first. Exiting." | |
| fscrypt status $ORIG_DIR | grep -q "is encrypted" && error_out "Your apps are already encrypted, exiting." | |
| [ -d $TMP_DIR ] && rm -rf $TMP_DIR | |
| echo "When asked to set up a new protector, choose N." | |
| echo "Continuing in 5 seconds..." | |
| sleep 5 | |
| mkdir $TMP_DIR | |
| FSCRYPT_ROOT_MNT=/userdata fscrypt encrypt $TMP_DIR --user=phablet | |
| echo "Migrating apps..." | |
| cp -a -T $ORIG_DIR $TMP_DIR | |
| chmod 755 $TMP_DIR | |
| chown clickpkg:clickpkg $TMP_DIR | |
| mv $ORIG_DIR $BAK_DIR | |
| mv $TMP_DIR $ORIG_DIR | |
| echo "Your apps have successfully been encrypted!" | |
| echo "An unencrypted backup has been stored in '$BAK_DIR', please reboot and remove it when you're comfortable." | |
| echo "Done! Exiting." | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment