Skip to content

Commit 1120415

Browse files
author
Marcus Funch
committed
Merge branch 'feature/49290_change_superuser_hidden_at_login' into 'master'
Add script to hide superuser, and optionally show custom user login field See merge request os2borgerpc/os2borgerpc-scripts!135
2 parents ef481c7 + 51ae118 commit 1120415

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#! /usr/bin/env sh
2+
3+
# Note: /etc/lighdm/users.conf has a setting to hide a user via this line:
4+
# hidden-users=nobody user2 user3
5+
# HOWEVER this doesn't work if an AccountService has been installed, and it has on Ubuntu incl. BorgerPC.
6+
# Hence we change it in the AccountService config instead.
7+
8+
# Reboot or run "systemctl restart lightdm" (which logs you out immediately) for it to take effect.
9+
10+
HIDE_SUPERUSER=$1
11+
SHOW_CUSTOM_LOGIN_FIELD=$2
12+
13+
CHOSEN_USER="superuser"
14+
ACCOUNT_SERVICE_SUPERUSER="/var/lib/AccountsService/users/$CHOSEN_USER"
15+
LIGHTDM_CONFIG="/etc/lightdm/lightdm.conf"
16+
17+
if [ "$HIDE_SUPERUSER" = "True" ]; then
18+
FROM="false"
19+
TO="true"
20+
else
21+
FROM="true"
22+
TO="false"
23+
fi
24+
25+
sed --in-place "s/SystemAccount=$FROM/SystemAccount=$TO/" $ACCOUNT_SERVICE_SUPERUSER
26+
27+
if [ "$SHOW_CUSTOM_LOGIN_FIELD" = "True" ]; then
28+
29+
# Idempotency: Don't add it if it's already there
30+
if ! grep -q -- "greeter-show-manual-login" "$LIGHTDM_CONFIG"; then
31+
sed -i '$ a greeter-show-manual-login=true' $LIGHTDM_CONFIG
32+
fi
33+
else
34+
sed -i '/greeter-show-manual-login/d' $LIGHTDM_CONFIG
35+
fi

0 commit comments

Comments
 (0)