Initial commit

This commit is contained in:
Alexandre CATTEAU 2023-06-24 19:57:57 +02:00
commit 58df3042b1
4 changed files with 54 additions and 0 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# APT autoremove
The purpose is to run `apt-get autoremove` regularly on systems. Main use-case is to remove old kernels on Ubuntu-based
systems, to free space in `/boot`.
### Files
* `systemd-templates/` contains Systemd units templates for running the the command unattended.
#### Installation
* `install.sh` script copies Systemd templates to their destination, and enables timer.
### TODO
* RAS

27
install.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
run_directory=$(dirname "$0")
user=$(whoami)
if [ -f $run_directory/.disabled ]; then
echo "Installation is disabled. Exiting..."
exit 0
fi
if [[ $user != 'root' ]]; then
sudo="sudo"
else
sudo=""
fi
echo "Copying Systemd units to system directory..."
$sudo cp systemd-templates/apt-autoremove.service systemd-templates/apt-autoremove.timer /etc/systemd/system/
echo "Reloading Systemd..."
$sudo systemctl daemon-reload
echo "Enabling timer (not starting it, either do it manually or reboot)..."
$sudo systemctl enable apt-autoremove.timer
echo "Finished install. Exiting..."
exit 0

View File

@ -0,0 +1,6 @@
[Unit]
Description=Run apt autoremove
[Service]
Type=oneshot
ExecStart=/usr/bin/apt-get autoremove -y

View File

@ -0,0 +1,9 @@
[Unit]
Description=Run apt-autoremove after boot (for desktops)
[Timer]
Unit=apt-autoremove.service
OnBootSec=2min
[Install]
WantedBy=timers.target