You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ublinux-init/ublinux/rc.post.d/16-kiosk-polkit

48 lines
1.5 KiB

#!/usr/bin/env bash
ENABLED=yes
[ "$ENABLED" != "yes" ] && exit 0
DEBUGMODE=no
SOURCE=/usr/lib/ublinux/functions; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null || exit 0
SOURCE=/usr/lib/ublinux/os-config; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null || exit 0
debug_mode "$0" "$@"
SOURCE=${SYSCONF}/config; [ -f ${SOURCE} ] && . ${SOURCE} 2>/dev/null
SOURCE=${SYSCONF}/kiosk; [[ -f ${SOURCE} ]] && . ${SOURCE} 2>/dev/null
## Настрока polkit правил
rm -f /etc/polkit-1/rules.d/kiosk-*
if [[ -n ${POLKIT[@]} ]]; then
for RULES in "${!POLKIT[@]}"; do
RULES_GROUP=
RULES_FILE="/etc/polkit-1/rules.d/kiosk-$(sed 's/\([A-z0-9]*.[A-z0-9]*.[A-z0-9]*\)\..*/\1/' <<< ${RULES}).rules"
RULES_RESULT=$(cut -d: -f1 <<< ${POLKIT[${RULES}]})
for GROUP in $(grep ":" <<< ${POLKIT[${RULES}]} | cut -d: -f2 | tr ',' '\n'); do
RULES_GROUP+="&& subject.isInGroup(\"${GROUP}\") "
done
cat >> ${RULES_FILE} <<EOF
polkit.addRule(function(action, subject) {
if (action.id.indexOf("${RULES}") == 0
&& subject.active == true
&& subject.local == true
${RULES_GROUP}
)
{
return polkit.Result.${RULES_RESULT^^};
}
});
EOF
done
# touch /etc/polkit-1/rules.d
# systemctl restart polkit
fi
# while read LSPCI_DEVICE; do
# while read KERNEL_MODULE; do
# [[ ${KERNEL_MODULE} != "nouveau" ]] && modprobe ${KERNEL_MODULE} 2>/dev/null && break
# done < <(lspci -ks ${LSPCI_DEVICE%% *} | grep 'Kernel modules:' | cut -d: -f2 | tr ',' '\n' | tac)
# done < <(lspci | egrep -i 'vga|3d')