forked from hiway/freedive
24 lines
536 B
Elixir
24 lines
536 B
Elixir
#!/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 %>
|