Skip to content

Commit

Permalink
uses systemd-run for the auto export in apt
Browse files Browse the repository at this point in the history
  • Loading branch information
taukakao authored and mirkobrombin committed Apr 17, 2024
1 parent 706ab7e commit cf26882
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions includes.container/usr/share/vso/hooks/apt-post
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/bash
if [ -z $SUDO_UID ]
then
echo "not running with sudo, export the app manually with vso export"
exit 0
fi

apt-mark showmanual > /tmp/vso-manually-installed-packages-after
installed_apps="$(grep -v -f /tmp/vso-manually-installed-packages-before /tmp/vso-manually-installed-packages-after)"

Expand All @@ -10,12 +16,11 @@ while IFS= read -r app_to_export
do
if [[ "x$app_to_export" == "x" ]]; then continue; fi
echo trying to export $app_to_export
echo "host-shell vso export --app $app_to_export" >> "$export_commands_file"
echo "vso export --app $app_to_export" >> "$export_commands_file"
done <<< "$installed_apps"

# run bash file as the user
if [ -s "$export_commands_file" ]
then
user_environment="XDG_RUNTIME_DIR=/run/user/$SUDO_UID; DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$SUDO_UID/bus;"
su -c "su -c \"$user_environment bash $export_commands_file > /dev/null 2> /dev/null \" $SUDO_USER"
systemd-run --user --machine="$SUDO_UID@.host" /usr/bin/host-shell bash $export_commands_file &> /dev/null
fi

0 comments on commit cf26882

Please sign in to comment.