#!/bin/sh

# Create global section
if ! uci -q get users.users; then
	uci -q set users.users='users'
fi

uci -q set users.users.auth_policy_enable='1'

# Create default authentication_policy section if missing
if ! uci -q get users.authentication_policy; then
	uci -q set users.authentication_policy='authentication_policy'
	uci -q set users.authentication_policy.enabled='1'
	uci -q set users.authentication_policy.fail_delay='3'
	uci -q set users.authentication_policy.faillock_attempts='6'
	uci -q set users.authentication_policy.faillock_lockout_time='300'
fi

# Create default passwdqc section if missing
if ! uci -q get users.passwdqc; then
	uci -q set users.passwdqc='passwdqc'
	uci -q set users.passwdqc.enabled='1'
	uci -q set users.passwdqc.min='disabled,disabled,disabled,8,8'
	uci -q set users.passwdqc.max='20'
	uci -q set users.passwdqc.passphrase='0'
	uci -q set users.passwdqc.retry='3'
	uci -q set users.passwdqc.enforce='everyone'
fi

exit 0
