Skip to content

Commit

Permalink
remove first-setup user after configuring the system
Browse files Browse the repository at this point in the history
  • Loading branch information
taukakao committed Feb 19, 2025
1 parent ee5a52c commit 33b1a2e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
17 changes: 17 additions & 0 deletions data/remove-first-setup-user
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions data/remove-first-setup-user.service
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions vanilla_first_setup/core/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", [])

Expand Down
1 change: 1 addition & 0 deletions vanilla_first_setup/scripts/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sources = [
'open-accessibility-settings',
'setup-system',
'user',
'remove-first-setup-user',
]

install_data(sources, install_dir: scriptsdir)
13 changes: 13 additions & 0 deletions vanilla_first_setup/scripts/remove-first-setup-user
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions vanilla_first_setup/views/logout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 33b1a2e

Please sign in to comment.