diff --git a/data/meson.build b/data/meson.build index 515e43d0..f5d1be98 100644 --- a/data/meson.build +++ b/data/meson.build @@ -58,4 +58,14 @@ if desktop_utils.found() ) endif +install_data( + 'remove-first-setup-user.service', + install_dir: join_paths(get_option('prefix'), 'lib', 'systemd', 'system') +) + +install_data( + 'remove-first-setup-user', + install_dir: get_option('libexecdir') +) + subdir('icons') diff --git a/data/remove-first-setup-user b/data/remove-first-setup-user new file mode 100755 index 00000000..d6835e2b --- /dev/null +++ b/data/remove-first-setup-user @@ -0,0 +1,17 @@ +#!/bin/bash +USERS_IN_FIRST_SETUP_GROUP=$(getent group "vanilla-first-setup" | awk -F: '{print $4}' | tr ',' ' ') + +for USER in $USER_LIST; do + if id "$USER" &>/dev/null; then + echo "Deleting first-setup user: $USER" + userdel -r "$USER" + if ! [ "$?" == 0 ]; then + exit 1 + fi + else + echo "User $USER does not exist." + fi +done + +rm /etc/systemd/system/multi-user.target.wants/remove-first-setup-user.service +exit 0 diff --git a/data/remove-first-setup-user.service b/data/remove-first-setup-user.service new file mode 100644 index 00000000..5e3afb12 --- /dev/null +++ b/data/remove-first-setup-user.service @@ -0,0 +1,10 @@ +[Unit] +Description=Remove the first-setup user from the system + +[Service] +ExecStart=/usr/libexec/remove-first-setup-user +Type=simple +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/vanilla_first_setup/core/backend.py b/vanilla_first_setup/core/backend.py index 30f79884..33049bf6 100644 --- a/vanilla_first_setup/core/backend.py +++ b/vanilla_first_setup/core/backend.py @@ -61,6 +61,9 @@ def disable_lockscreen(): def setup_flatpak_remote(): return run_script("setup-flatpak-remote", []) +def remove_first_setup_user(): + return run_script("remove-first-setup-user", [], root=True) + def _setup_system(): return run_script("setup-system", []) diff --git a/vanilla_first_setup/scripts/meson.build b/vanilla_first_setup/scripts/meson.build index 4ff21789..8e2afdde 100755 --- a/vanilla_first_setup/scripts/meson.build +++ b/vanilla_first_setup/scripts/meson.build @@ -16,6 +16,7 @@ sources = [ 'open-accessibility-settings', 'setup-system', 'user', + 'remove-first-setup-user', ] install_data(sources, install_dir: scriptsdir) diff --git a/vanilla_first_setup/scripts/remove-first-setup-user b/vanilla_first_setup/scripts/remove-first-setup-user new file mode 100755 index 00000000..1d1c0008 --- /dev/null +++ b/vanilla_first_setup/scripts/remove-first-setup-user @@ -0,0 +1,13 @@ +#!/bin/bash +if ! [ -z "$1" ]; then + echo "usage:" + echo "remove-first-setup-user" + exit 5 +fi + +if ! [ "$UID" == "0" ]; then + echo "this script must be run with super user privileges" + exit 6 +fi + +systemctl enable remove-first-setup-user.service diff --git a/vanilla_first_setup/views/logout.py b/vanilla_first_setup/views/logout.py index ba8bd0d5..6f12142c 100644 --- a/vanilla_first_setup/views/logout.py +++ b/vanilla_first_setup/views/logout.py @@ -41,6 +41,7 @@ def __init__( self.btn_login.connect("clicked", self.__on_login_clicked) def set_page_active(self): + backend.remove_first_setup_user() has_errors = len(backend.errors) > 0 self.btn_logs.set_visible(has_errors) self.btn_login.grab_focus()