'';
};
normalUsers = serverSpecificConfig.users;
+ userquotas = pkgs.writeScriptBin "user_quotas" ''
+ #!/usr/bin/env bash
+ set -euo pipefail
+
+ if [ `whoami` != "root" ]; then
+ list=$(id -u)
+ else
+ list="${builtins.concatStringsSep " " (lib.mapAttrsToList (n: v: builtins.toString v.uid) normalUsers)}"
+ fi
+
+ get_size () {
+ user=$1
+ home=$((du -sbx /home/$user 2>/dev/null | cut -d" " -f1) || echo 0)
+ nextcloud=$((du -sbx /home/var_lib/nextcloud/data/$user 2>/dev/null | cut -d" " -f1) || echo 0)
+ echo "Home: $(numfmt --to=iec "$home")"
+ echo "Nextcloud: $(numfmt --to=iec "$nextcloud")"
+ echo "Raw: $(($home + $nextcloud))"
+ }
+
+ for user in $list; do
+ group=$(id -ng "$user")
+ size=$(get_size "$group")
+ total=$(echo "$size" | grep ^Raw | cut -d" " -f2)
+ decomp=" $group: $(numfmt --to=iec "$total")"
+ decomp="$decomp;$(echo "$size" | grep -v ^Raw | sed -e "s/^/ /")"
+
+ sponsored=$(getent group $group | cut -d':' -f4)
+ IFS=","
+ for subuser in $sponsored; do
+ size=$(get_size "$subuser")
+ totalsub=$(echo "$size" | grep ^Raw | cut -d" " -f2)
+ total=$(($total + $totalsub))
+ decomp="$decomp; $subuser: $(numfmt --to=iec "$totalsub")"
+ decomp="$decomp;$(echo "$size" | grep -v ^Raw | sed -e "s/^/ /")"
+ done
+ echo "$group: $(numfmt --to=iec "$total")"
+ echo "$decomp" | tr ";" "\n"
+ done
+ '';
sponsoredUser = pkgs.writeScriptBin "sponsored_user" ''
#!/usr/bin/env bash
{
deployment = {
targetUser = "root";
- targetHost = config.hostEnv.ips.main.ip4;
+ targetHost = lib.head config.hostEnv.ips.main.ip4;
substituteOnDestination = true;
};
# ssh-keyscan quatresaison | nix-shell -p ssh-to-age --run ssh-to-age
'';
};
- secrets.keys = [
- {
- dest = "ldap/sync_password";
+ secrets.keys = {
+ "ldap/sync_password" = {
permissions = "0400";
text = serverSpecificConfig.ldap_sync_password;
- }
- {
- dest = "ldap/ldaptree.ldif";
+ };
+ "ldap/ldaptree.ldif" = {
permissions = "0400";
text = serverSpecificConfig.ldap_service_users
+ (builtins.concatStringsSep "\n" (lib.mapAttrsToList (n: v: ''
sn: ${n}
uid: ${n}
'') normalUsers));
- }
- ];
+ };
+ };
myServices.monitoring.enable = true;
myServices.certificates.enable = true;
];
environment.systemPackages = [
- sponsoredUser
+ sponsoredUser userquotas
pkgs.git pkgs.vim pkgs.rsync pkgs.strace pkgs.home-manager
- pkgs.telnet pkgs.htop pkgs.iftop pkgs.bind.dnsutils pkgs.httpie
- pkgs.iotop pkgs.whois pkgs.ngrep pkgs.tcpdump pkgs.tshark
+ pkgs.inetutils pkgs.htop pkgs.iftop pkgs.bind.dnsutils pkgs.httpie
+ pkgs.iotop pkgs.whois pkgs.ngrep pkgs.tcpdump pkgs.wireshark-cli
pkgs.tcpflow pkgs.nmap pkgs.p0f pkgs.socat pkgs.lsof pkgs.psmisc
pkgs.openssl pkgs.wget pkgs.pv pkgs.smartmontools pkgs.youtube-dl
pkgs.unzip pkgs.octave pkgs.feh pkgs.xv pkgs.sshfs pkgs.gdb
'' ];
ips =
let ips = config.hostEnv.ips.main;
- in [ips.ip4] ++ (ips.ip6 or []);
+ in (ips.ip4 or []) ++ (ips.ip6 or []);
fallbackVhost = {
certName = "quatresaisons";