Skip to content

Commit

Permalink
debian: fix config migration
Browse files Browse the repository at this point in the history
  • Loading branch information
neolynx committed Sep 17, 2024
1 parent ffea1c0 commit e7f617f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 9 additions & 0 deletions debian/aptly-api.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ case "$1" in
# set config file permissions not world readable as it may contain secrets
chown root:aptly-api /etc/aptly.conf
chmod 640 /etc/aptly.conf

if [ -f /etc/aptly-api.conf.migrate ]; then
rootDir=`grep rootDir /etc/aptly-api.conf.migrate | sed 's_/var/lib/aptly-api_~_' | sed -n 's/.\+: "\([^"]\+\)".*/\1/p'`
if [ -n "$rootDir" ]; then
sed -i 's/\(.*"rootDir": "\)[^"]\+\(".*\)/\1'$rootDir'\2/' /etc/aptly.conf
fi
echo "backing up /etc/aptly-api.conf to /etc/aptly-api.conf.old..."
mv /etc/aptly-api.conf.migrate /etc/aptly-api.conf.old
fi
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand Down
6 changes: 2 additions & 4 deletions debian/aptly-api.preinst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ set -e
case "$1" in
install|upgrade)
if [ -f /etc/aptly-api.conf ]; then
echo "migrating /etc/aptly-api.conf to /etc/aptly.conf ..."
cp /etc/aptly-api.conf /etc/aptly.conf
mv /etc/aptly-api.conf /etc/aptly-api.conf.old
sed -i 's_/var/lib/aptly-api_~/.aptly_' /etc/aptly.conf
echo "migrating /etc/aptly-api.conf ..."
mv /etc/aptly-api.conf /etc/aptly-api.conf.migrate
fi
;;

Expand Down

0 comments on commit e7f617f

Please sign in to comment.