Permission fixes for rmlint script (#1191)

* Permission fixes for rmlint script

Forgot to run sudo before creating files into /etc

* Small typo fix

* Add an external file to copy back

I can't get cat to properly parse and escape it correctly from an inline bash script
This commit is contained in:
Marco Rodolfi 2024-05-31 18:38:25 +02:00 committed by GitHub
parent c8275031d1
commit bea94c2f11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 5 deletions

View File

@ -6,7 +6,7 @@ enable-rmlint ACTION="":
source /usr/lib/ujust/ujust.sh
OPTION={{ ACTION }}
if [[ ! -f "/etc/systemd/system/btrfs-dedup@.service.d/override.conf" ]]; then
RMLINT_STATE="${red}${b}not enabled{n}"
RMLINT_STATE="${red}${b}not enabled${n}"
else
RMLINT_STATE="${green}${b}already enabled${n}"
fi
@ -28,8 +28,8 @@ enable-rmlint ACTION="":
fi
ublue-update --wait
rpm-ostree install --apply-live -y rmlint
mkdir /etc/systemd/system/btrfs-dedup@.service.d/
bash -c 'cat << EOL > /etc/systemd/system/btrfs-dedup@.service.d/override.conf
sudo mkdir /etc/systemd/system/btrfs-dedup@.service.d/
sudo bash -c 'cat << EOL > /etc/systemd/system/btrfs-dedup@.service.d/override.conf
[Unit]
Description=Btrfs deduplication on %f
ConditionPathIsMountPoint=%f
@ -69,7 +69,7 @@ enable-rmlint ACTION="":
fi
ublue-update --wait
rpm-ostree remove -y rmlint
rm /etc/systemd/system/btrfs-dedup@.service.d/override.conf
rmdir /etc/systemd/system/btrfs-dedup@.service.d/
sudo rm /etc/systemd/system/btrfs-dedup@.service.d/override.conf
sudo rmdir /etc/systemd/system/btrfs-dedup@.service.d/
echo "rmlint has been disabled."
fi

View File

@ -0,0 +1,30 @@
[Unit]
Description=Btrfs deduplication on %f
ConditionPathIsMountPoint=%f
RequiresMountsFor=%f
[Service]
Type=oneshot
MemoryHigh=1G
ExecCondition=sh -c '[ "$(stat -f -c "%%T" "$1")" = btrfs ]' _ %f/
ExecStartPre=-find %f/ -mindepth 1 -maxdepth 1 -mtime +14 -name .duperemove.hash -exec rm -f '{}' \;
ExecStartPre=-cp -a %f/.duperemove.hash duperemove.hash
ExecStartPre=-compsize %f/
ExecStart=rmlint --hidden --types="duplicates" --config=sh:handler=clone %f/
ExecStart=sh -c 'exec ./rmlint.sh -d -p -r -k'
ExecStart=-compsize %f/
ExecStart=-sh -c '[ "$(sqlite3 -readonly duperemove.hash "SELECT keyval FROM config where keyname=''version_major''")" -ge 4 ] || rm -f duperemove.hash'
ExecStart=duperemove -r -d -h -q --hashfile=duperemove.hash --skip-zeroes --exclude="%f/.duperemove.hash" --exclude="%f/@swapfile/swapfile" %f/
ExecStartPost=-compsize %f/
ExecStopPost=-cp -a duperemove.hash %f/.duperemove.hash
TimeoutStartSec=4h
RuntimeDirectory=%p/%i
WorkingDirectory=%t/%p/%i
Nice=19
CPUSchedulingPolicy=batch
IOSchedulingClass=best-effort
IOSchedulingPriority=7
OOMScoreAdjust=1000
CPUWeight=30
CPUQuota=300%
IOWeight=30