Initial commit
This commit is contained in:
commit
58df3042b1
12
README.md
Normal file
12
README.md
Normal 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
27
install.sh
Executable 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
|
6
systemd-templates/apt-autoremove.service
Normal file
6
systemd-templates/apt-autoremove.service
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Run apt autoremove
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/apt-get autoremove -y
|
9
systemd-templates/apt-autoremove.timer
Normal file
9
systemd-templates/apt-autoremove.timer
Normal 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
|
Loading…
Reference in New Issue
Block a user