Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,15 @@ meson install -C build

### Creating initial user

A special user is needed to run the initial setup for hostname, user-creation, locale, etc.

1. Create a user
2. Create the group vanilla-first-setup (Changing the gid is recommended to avoid messing with user groups)
3. Add the user to group vanilla-first-setup
4. Create the file `/var/lib/AccountsService/users/your_user`
```ini
[User]
Session=firstsetup
```
5. Create the file `/etc/gdm3/daemon.conf` (replace your_user)
```ini
[daemon]
AutomaticLogin=your_user
AutomaticLoginEnable=True
A special user is needed to run the initial setup for hostname, user-creation, locale, etc. Configuration varies depending on your DE and DM.

1. Run `systemd-sysusers` to create the first-setup user.
2. Run `systemd-tmpfiles --create` to create AccountService and GDM configuration.

```

> [!WARNING]
> All users in this group will be deleted on the first reboot after a successful first setup.
> All users in `vanilla-first-setup` group will be deleted on the first reboot after a successful first setup.

### Running
```bash
Expand Down
30 changes: 30 additions & 0 deletions data/first-setup-bootutil
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -euo pipefail

if [ -e /etc/vanilla-first-setup/finalized ]; then
echo "first setup already finalized, nothing to do."
exit 0
fi

if ! id vanilla &>/dev/null; then
echo "first-setup user 'vanilla' does not exist, nothing to do."
exit 0
fi

install -d -m 0700 /var/lib/AccountsService/users
cat > /var/lib/AccountsService/users/vanilla <<EOF
[User]
Session=firstsetup
EOF
chmod 0600 /var/lib/AccountsService/users/vanilla

install -d -m 0755 /etc/gdm3
cat > /etc/gdm3/daemon.conf <<EOF
[daemon]
AutomaticLogin=vanilla
AutomaticLoginEnable=True
EOF
chmod 0644 /etc/gdm3/daemon.conf

echo "first-setup autologin configured for 'vanilla'."
14 changes: 14 additions & 0 deletions data/first-setup-bootutil.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Vanilla OS First Setup Boot Utility
Documentation=https://github.com/Vanilla-OS/first-setup
Wants=systemd-sysusers.service
After=systemd-sysusers.service
Before=display-manager.service

[Service]
Type=oneshot
ExecStart=/usr/libexec/first-setup-bootutil
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions data/firstsetup-tmpfiles.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
d /home/vanilla - - - - -

Z /home/vanilla 0750 vanilla vanilla-first-setup - -
5 changes: 5 additions & 0 deletions data/firstsetup.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
u vanilla - "Vanilla First Setup User" /home/vanilla /bin/sh

g vanilla-first-setup - -

m vanilla vanilla-first-setup
50 changes: 42 additions & 8 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ desktop_file = i18n.merge_file(
install_dir: join_paths(get_option('datadir'), 'applications'),
)

custom_target(
'install-autostart-desktop',
input: desktop_file,
output: 'org.vanillaos.FirstSetup.autostart.desktop',
command: ['cp', '@INPUT@', '@OUTPUT@'],
install_dir: join_paths(get_option('sysconfdir'), 'xdg', 'autostart'),
build_by_default: true,
install : true,
systemd_userunitdir = join_paths(get_option('prefix'), 'lib', 'systemd', 'user')

install_data(
'org.vanillaos.FirstSetup.service',
install_dir: systemd_userunitdir,
)

wantsdir = join_paths(get_option('prefix'), 'lib', 'systemd', 'user', 'gnome-session.target.wants')
meson.add_install_script(
'sh', '-c',
'install -d "$MESON_INSTALL_DESTDIR_PREFIX/' + wantsdir + '" && ' +
'ln -sf ../org.vanillaos.FirstSetup.service "$MESON_INSTALL_DESTDIR_PREFIX/' + wantsdir + '/"'
)

desktop_utils = find_program('desktop-file-validate', required: false)
Expand All @@ -66,4 +70,34 @@ install_data(
install_dir: join_paths(get_option('prefix'), 'libexec')
)

install_data(
'firstsetup.conf',
install_dir: join_paths(get_option('prefix'), 'lib', 'sysusers.d')
)

install_data(
'firstsetup-tmpfiles.conf',
install_dir: join_paths(get_option('prefix'), 'lib', 'tmpfiles.d')
)

systemd_systemunitdir = join_paths(get_option('prefix'), 'lib', 'systemd', 'system')

install_data(
'first-setup-bootutil.service',
install_dir: systemd_systemunitdir,
)

install_data(
'first-setup-bootutil',
install_dir: join_paths(get_option('prefix'), 'libexec'),
install_mode: 'rwxr-xr-x',
)

multi_user_wantsdir = join_paths(systemd_systemunitdir, 'multi-user.target.wants')
meson.add_install_script(
'sh', '-c',
'install -d "$MESON_INSTALL_DESTDIR_PREFIX/' + multi_user_wantsdir + '" && ' +
'ln -sf ../first-setup-bootutil.service "$MESON_INSTALL_DESTDIR_PREFIX/' + multi_user_wantsdir + '/"'
)

subdir('icons')
13 changes: 13 additions & 0 deletions data/org.vanillaos.FirstSetup.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Vanilla OS First Setup
RefuseManualStart=true
RefuseManualStop=true

BindsTo=gnome-session.target
After=gnome-session.target
After=org.gnome.Shell@firstsetup.service

[Service]
Type=simple
ExecStart=/usr/bin/vanilla-first-setup
Restart=no
25 changes: 11 additions & 14 deletions data/remove-first-setup-user
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#!/bin/bash
USERS_IN_FIRST_SETUP_GROUP=$(getent group "vanilla-first-setup" | awk -F: '{print $4}' | tr ',' ' ')

for USER in $USERS_IN_FIRST_SETUP_GROUP; do
if id "$USER" &>/dev/null; then
echo "Deleting first-setup user: $USER"
userdel -r "$USER"
if ! [ "$?" == 0 ]; then
exit 1
fi
rm "/var/lib/AccountsService/users/$USER"
else
echo "User $USER does not exist."
fi
done
set -uo pipefail

rm -f /etc/gdm3/daemon.conf

rm -f /var/lib/AccountsService/users/vanilla

install -d -m 0755 /etc/vanilla-first-setup
touch /etc/vanilla-first-setup/finalized

systemctl disable remove-first-setup-user.service

rm /etc/systemd/system/multi-user.target.wants/remove-first-setup-user.service
exit 0

3 changes: 3 additions & 0 deletions data/remove-first-setup-user.service
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[Unit]
Description=Remove the first-setup user from the system
Documentation=https://github.com/Vanilla-OS/first-setup
After=first-setup-bootutil.service
Before=display-manager.service

[Service]
ExecStart=/usr/libexec/remove-first-setup-user
Expand Down
Loading