summaryrefslogtreecommitdiffstats
path: root/images/gen_key_migration_script/templates
diff options
context:
space:
mode:
Diffstat (limited to 'images/gen_key_migration_script/templates')
-rw-r--r--images/gen_key_migration_script/templates/key-migration.sh34
1 files changed, 16 insertions, 18 deletions
diff --git a/images/gen_key_migration_script/templates/key-migration.sh b/images/gen_key_migration_script/templates/key-migration.sh
index 879022a..56acb4f 100644
--- a/images/gen_key_migration_script/templates/key-migration.sh
+++ b/images/gen_key_migration_script/templates/key-migration.sh
@@ -14,21 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-PACKAGES=/data/system/packages.xml
-PACKAGES_BACKUP=/data/system/packages-backup.xml
-MIGRATION_DONE=/data/system/.key-migration-done
-
-if [ -f ${MIGRATION_DONE} ]; then
- exit 0
-fi
-
-if [ ! -f ${PACKAGES_BACKUP} ] && [ ! -f ${PACKAGES} ]; then
- touch ${MIGRATION_DONE}
- exit 0
-fi
-
-if [ -f ${PACKAGES_BACKUP} ]; then
- mv ${PACKAGES_BACKUP} ${PACKAGES}
+PACKAGES="/data/system/packages.xml"
+
+if [ ! -f "${PACKAGES}" ]; then
+ echo "Cannot migrate keys due to missing ${PACKAGES}:"
+ echo "- If /data is not mounted, you might need to mount it"
+ echo "- If /data is already mounted, maybe the data partition is blank."
+ echo " In this case you can skip running this script."
+ exit 0
fi
#####################
@@ -37,7 +30,12 @@ fi
{{ generate_shell_commands(certs_data) }}
-chmod 660 ${PACKAGES}
-chown system:system ${PACKAGES}
+if [ "$(find /data/system/packages.xml -perm 660)" != "${PACKAGES}" ] ; then
+ chmod 660 ${PACKAGES}
+fi
+
+if [ "$(find /data/system/packages.xml -user system -group system)" != "${PACKAGES}" ] ; then
+ chown system:system ${PACKAGES}
+fi
-touch ${MIGRATION_DONE}
+echo "Key migration done"