Skip to content

Commit

Permalink
Merge pull request #4 from sysrich/localemig
Browse files Browse the repository at this point in the history
Support migrating existing user local & system time settings
  • Loading branch information
sysrich authored May 13, 2024
2 parents 071ee87 + 3f6410b commit 144530a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion usr/lib/tik/modules/post/20-mig
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ if [ "${migrate}" == 1 ]; then
prun /usr/bin/cat ${mig_dir}/passwd.out | prun tee -a ${mig_dir}/mnt/etc/passwd
prun /usr/bin/cat ${mig_dir}/shadow.out | prun tee -a ${mig_dir}/mnt/etc/shadow
prun /usr/bin/sed -i "/^wheel:/ s/$/$(head -n 1 ${mig_dir}/passwd.out | awk -F'[/:]' '{print $1}')/" ${mig_dir}/mnt/etc/group
# It's not guaranteed that the system will have existing network configs
# It's not guaranteed that the system will have existing network configs, localtime or AccountsService
prun-opt /usr/bin/cp -a ${mig_dir}/system-connections/* ${mig_dir}/mnt/etc/NetworkManager/system-connections
prun-opt /usr/bin/cp -a ${mig_dir}/localtime ${mig_dir}/mnt/etc/localtime
prun-opt /usr/bin/cp -a ${mig_dir}/users/* ${mig_dir}/mnt/var/lib/AccountsService/users
prun-opt /usr/bin/cp -a ${mig_dir}/icons/* ${mig_dir}/mnt/var/lib/AccountsService/icons
prun /usr/bin/umount ${mig_dir}/mnt/etc
prun /usr/bin/umount ${mig_dir}/mnt/var
prun /usr/bin/umount ${mig_dir}/mnt
Expand Down
10 changes: 9 additions & 1 deletion usr/lib/tik/modules/pre/20-mig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ if [ ! -z "$(ls -A ${mig_dir})" ]; then
prun-opt /usr/bin/rm ${mig_dir}/*.out
prun-opt /usr/bin/rm ${mig_dir}/system-connections/*
prun-opt /usr/bin/rmdir ${mig_dir}/system-connections
prun-opt /usr/bin/rm ${mig_dir}/users/*
prun-opt /usr/bin/rmdir ${mig_dir}/users
prun-opt /usr/bin/rm ${mig_dir}/icons/*
prun-opt /usr/bin/rmdir ${mig_dir}/icons
prun-opt /usr/bin/rm ${mig_dir}/localtime
fi
fi

Expand Down Expand Up @@ -114,8 +119,11 @@ if [ -z "${skipbackup}" ]; then
eval prun "$etcmntcmd"
prun /usr/bin/awk -F'[/:]' '($3 >= 1000 && $3 != 65534)' ${mig_dir}/mnt/etc/passwd | prun tee ${mig_dir}/passwd.out
prun /usr/bin/awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' ${mig_dir}/mnt/etc/passwd | prun /usr/bin/grep -f - ${mig_dir}/mnt/etc/shadow | prun tee ${mig_dir}/shadow.out
# It's not guaranteed that the system will have existing network configs
# It's not guaranteed that the system will have existing network configs, custom localtime or AccountsService
prun-opt /usr/bin/cp -a ${mig_dir}/mnt/etc/NetworkManager/system-connections ${mig_dir}/system-connections
prun-opt /usr/bin/cp -a ${mig_dir}/mnt/etc/localtime ${mig_dir}/localtime
prun-opt /usr/bin/cp -a ${mig_dir}/mnt/var/lib/AccountsService/users ${mig_dir}/users
prun-opt /usr/bin/cp -a ${mig_dir}/mnt/var/lib/AccountsService/icons ${mig_dir}/icons
prun /usr/bin/umount ${mig_dir}/mnt/etc
prun /usr/bin/umount ${mig_dir}/mnt/var
prun /usr/bin/umount ${mig_dir}/mnt
Expand Down

0 comments on commit 144530a

Please sign in to comment.