mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
usermngr: Added admin,user users in default config
This commit is contained in:
parent
d234e7adcc
commit
86ede4ab6b
3 changed files with 60 additions and 2 deletions
|
|
@ -5,7 +5,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=usermngr
|
||||
PKG_VERSION:=1.3.8
|
||||
PKG_VERSION:=1.3.9
|
||||
|
||||
LOCAL_DEV:=0
|
||||
ifneq ($(LOCAL_DEV),1)
|
||||
|
|
@ -50,7 +50,8 @@ define Package/usermngr/install
|
|||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_DIR) $(1)/etc/users/roles
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/91-sync-shells $(1)/etc/uci-defaults/91-sync-shells
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/91-sync-shells $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/uci-defaults/91-sync-roles $(1)/etc/uci-defaults/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/users $(1)/etc/init.d/users
|
||||
$(INSTALL_BIN) ./files/etc/config/users $(1)/etc/config/users
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/usermngr $(1)/usr/sbin/usermngr
|
||||
|
|
|
|||
|
|
@ -2,3 +2,10 @@ config users 'users'
|
|||
option enabled '1'
|
||||
option loglevel '3'
|
||||
|
||||
config user 'admin'
|
||||
option enabled '1'
|
||||
option member_roles 'admin'
|
||||
|
||||
config user 'user'
|
||||
option enabled '1'
|
||||
option member_roles 'user'
|
||||
|
|
|
|||
50
usermngr/files/etc/uci-defaults/91-sync-roles
Normal file
50
usermngr/files/etc/uci-defaults/91-sync-roles
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
if [ -f "/usr/local/share/libubox/jshn.sh" ]; then
|
||||
. /usr/local/share/libubox/jshn.sh
|
||||
else
|
||||
. /usr/share/libubox/jshn.sh
|
||||
fi
|
||||
|
||||
USERMNGR_DIR="/etc/users/roles"
|
||||
|
||||
add_static_roles() {
|
||||
local role role_files rname rinst
|
||||
|
||||
role_files="$(ls -1 ${USERMNGR_DIR}/*.json)"
|
||||
|
||||
for role in ${role_files}; do
|
||||
json_init
|
||||
json_load_file "${role}"
|
||||
json_select tr181
|
||||
json_get_var rname name
|
||||
json_get_var rinst instance
|
||||
|
||||
uci -q set users.role_${rname}=role
|
||||
uci -q set users.role_${rname}.enabled="1"
|
||||
uci -q set users.role_${rname}.role_id="${rinst}"
|
||||
uci -q set users.role_${rname}.name="${rname}"
|
||||
uci -q set users.role_${rname}.static="1"
|
||||
done
|
||||
}
|
||||
|
||||
remove_invalid_static_roles() {
|
||||
local name static
|
||||
|
||||
config_get name "$1" name ""
|
||||
config_get_bool static "$1" static "0"
|
||||
|
||||
if [ "${static}" -eq "1" ]; then
|
||||
if [ ! -f "${USERMNGR_DIR}/${name}.json" ]; then
|
||||
echo "Role file not present, deleting ${1} role"
|
||||
uci -q delete users."$1"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
config_load users
|
||||
config_foreach remove_invalid_static_roles role
|
||||
add_static_roles
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Reference in a new issue