summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefanie Eckner <stefanie@eckner.net>2024-03-16 11:28:48 +0100
committerStefanie Eckner <stefanie@eckner.net>2024-03-16 11:28:48 +0100
commit85da5aa7c3cba6704a834484c1540434c04442eb (patch)
tree39126b5209c8c931a958ae9d551a77bf8c0ad54e
parent02dbaca95c6549e4ecf3764297c0c68b83b704c2 (diff)
downloadcomputer-time-limit-85da5aa7c3cba6704a834484c1540434c04442eb.tar.xz
read users from config
-rwxr-xr-xcomputer-time-limit17
1 files changed, 4 insertions, 13 deletions
diff --git a/computer-time-limit b/computer-time-limit
index 638a2d7..c27dca1 100755
--- a/computer-time-limit
+++ b/computer-time-limit
@@ -18,15 +18,7 @@ if [ -d "${dir}"'/.git' ] && [ $# -eq 0 ] && [ "$(stat -c%U "${dir}"'/.git')" =
fi
fi
-mapfile -t users < <(
- cut -d: -f1,6 /etc/passwd \
- | while IFS=':' read -r user home; do
- dir="${home}/.local/keys"
- [ -d "${dir}" ] || continue
- find "${dir}" -mindepth 1 -maxdepth 1 -type f -name '*.sec' -printf "${user}"' %p\n' \
- | head -n1
- done
-)
+. /etc/computer-time-limit.conf
sende_msg() {
curl \
@@ -107,7 +99,7 @@ is_logged_in() {
}
stop_all() {
- for key_file in "${users[@]#* }"; do
+ for key_file in "${keys[@]}"; do
sende_msg stop "${key_file}"
done
}
@@ -117,9 +109,8 @@ noch=0
ab=$(date +%s)
while true; do
- for user_and_key in "${users[@]}"; do
- user="${user_and_key%% *}"
- key="${user_and_key#* }"
+ for user in "${!keys[@]}"; do
+ key="${keys["${user}"]}"
if is_logged_in "${user}"; then
wie_lange_noch "${key}"
check_time "${user}" "${key}"