freedive/priv/freebsd/pre-install.sh.eex

25 lines
536 B
Elixir
Raw Normal View History

2024-05-13 17:26:07 +02:00
#!/bin/sh
ensure_user() {
group=$1
user=$1
if pw groupshow $group 2>/dev/null; then
echo "Group '$group' already exists."
else
echo "Creating group '$group'."
pw groupadd $group
fi
if id $user 2>/dev/null; then
echo "User '$user' already exists."
else
echo "Creating user '$user' with group '$group'."
pw useradd $user -g $group -s /usr/sbin/nologin -d /nonexistent
fi
}
<%= if @user != "root" do %>
ensure_user "<%= @user %>" "<%= @user %>"
<% end %>