Fix learner-add.sh for NixOS compatibility

- Use 'users' group instead of per-user groups
- Remove shell specification (NixOS has different paths)
- Use 'ip' command instead of 'hostname -I' for IP detection
This commit is contained in:
Dan 2025-12-29 00:08:18 -05:00
parent 3d33a45cc9
commit 29ce3a9fa5

View file

@ -65,7 +65,8 @@ create_user() {
log_info "Creating user '$username'..."
# Create user with home directory
useradd -m -s /bin/bash "$username"
# NixOS: don't specify shell (uses default), group is 'users'
useradd -m -g users "$username"
# Set up SSH key
local ssh_dir="/home/$username/.ssh"
@ -73,7 +74,7 @@ create_user() {
echo "$ssh_key" > "$ssh_dir/authorized_keys"
chmod 700 "$ssh_dir"
chmod 600 "$ssh_dir/authorized_keys"
chown -R "$username:$username" "$ssh_dir"
chown -R "$username:users" "$ssh_dir"
log_info "User created with SSH access"
}
@ -109,7 +110,7 @@ setup_plugin_directory() {
fi
# Set ownership
chown -R "$username:$username" "$user_plugins_dir"
chown -R "$username:users" "$user_plugins_dir"
# Make plugin dir readable by maubot group
chmod 755 "/home/$username"
@ -243,7 +244,8 @@ create_maubot_symlink() {
print_onboarding() {
local username="$1"
local server_ip
server_ip=$(hostname -I | awk '{print $1}')
# NixOS: use ip command instead of hostname -I
server_ip=$(ip -4 addr show scope global | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -1)
echo ""
echo "=========================================="