final adjustments to the slop
This commit is contained in:
@@ -28,6 +28,7 @@ in
|
|||||||
};
|
};
|
||||||
holocron = {
|
holocron = {
|
||||||
copyparty.enable = true;
|
copyparty.enable = true;
|
||||||
|
ensure_perms.enable = true;
|
||||||
zfs.enable = true;
|
zfs.enable = true;
|
||||||
smb.enable = true;
|
smb.enable = true;
|
||||||
nfs.enable = true;
|
nfs.enable = true;
|
||||||
|
|||||||
@@ -17,40 +17,44 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
# service to run periodically to reset the perms on all zpools
|
# service to run periodically to reset the perms on all zpools
|
||||||
# everything works fine without this, just for peace of mind
|
# everything works fine without this, just for peace of mind
|
||||||
# and to clean up the ownership from the arr stack in /holocron/media
|
# and to clean up the ownership from the arr stack in /holocron/media
|
||||||
systemd.services.${service} = {
|
systemd.services.${service} = {
|
||||||
description = "ensure file permissions for archives, media and user folders";
|
description = "ensure file permissions for archives, media and user folders";
|
||||||
serviceConfig.ExecStart = ''
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Fix ownership for archives directory
|
|
||||||
chown -R root:archives ${archives_path}
|
|
||||||
chmod -R 2770 ${archives_path}
|
|
||||||
|
|
||||||
# Fix ownership for media directory
|
|
||||||
chown -R root:media ${media_path}
|
|
||||||
chmod -R 2770 ${media_path}
|
|
||||||
|
|
||||||
# Fix user directories
|
|
||||||
for user_dir in ${users_path}/*; do
|
|
||||||
if [ -d "$user_dir" ]; then
|
|
||||||
user=$(basename "$user_dir")
|
|
||||||
chown -R "$user:$user" "$user_dir"
|
|
||||||
chmod -R 700 "$user_dir"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
type = "oneshot";
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
ExecStart = ''
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Fix ownership for archives directory
|
||||||
|
chown -R root:archives ${archives_path}
|
||||||
|
chmod -R 2770 ${archives_path}
|
||||||
|
|
||||||
|
# Fix ownership for media directory
|
||||||
|
chown -R root:media ${media_path}
|
||||||
|
chmod -R 2770 ${media_path}
|
||||||
|
|
||||||
|
# Fix user directories
|
||||||
|
for user_dir in ${users_path}/*; do
|
||||||
|
if [ -d "$user_dir" ]; then
|
||||||
|
user=$(basename "$user_dir")
|
||||||
|
chown -R "$user:$user" "$user_dir"
|
||||||
|
chmod -R 700 "$user_dir"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# timer to run the service periodically (e.g., daily)
|
|
||||||
systemd.timers.${service} = {
|
systemd.timers.${service} = {
|
||||||
description = "run script to ensure_perms daily";
|
description = "run script to ensure_perms daily";
|
||||||
timerConfig.OnCalendar = "daily"; # Can be adjusted to hourly, weekly, etc.
|
wantedBy = ["timers.target"];
|
||||||
unit = "${service}.service";
|
timerConfig = {
|
||||||
|
OnCalendar = "daily";
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user