Move /sbin to /bin

As more users would have /bin than /sbin in their PATH
This commit is contained in:
Erik Westrup
2022-02-07 18:22:33 +01:00
parent 54e2d17e23
commit 645df1a0d4
15 changed files with 19 additions and 19 deletions
+2 -2
View File
@@ -7,13 +7,13 @@ on:
paths: paths:
- '**.sh' - '**.sh'
- '.github/workflows/linter.yml' - '.github/workflows/linter.yml'
- 'usr/local/sbin/**' - 'bin/**'
pull_request: pull_request:
branches: master branches: master
paths: paths:
- '**.sh' - '**.sh'
- '.github/workflows/linter.yml' - '.github/workflows/linter.yml'
- 'usr/local/sbin/**' - 'bin/**'
jobs: jobs:
build: build:
name: Lint Code Base name: Lint Code Base
+1 -1
View File
@@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# systemctl disable restic-backup@<profile>.timer # systemctl disable restic-backup@<profile>.timer
# systemctl enable restic-backup@<profile>.timer # systemctl enable restic-backup@<profile>.timer
``` ```
- **BREAKING CHANGE** moved script installation with makefile from `/usr/local/sbin` to `/sbin` to have a simpler interface to work with `$PREFIX`. - **BREAKING CHANGE** moved script installation with makefile from `/usr/local/sbin` to `/bin` to have a simpler interface to work with `$PREFIX`.
- Renamed top level make install targets. The old `$ make install` is now `$ make install-systemd` - Renamed top level make install targets. The old `$ make install` is now `$ make install-systemd`
### Fixed ### Fixed
+1 -1
View File
@@ -39,7 +39,7 @@ MKDIR_PARENTS=sh -c '\
' MKDIR_PARENTS ' MKDIR_PARENTS
# Source directories. # Source directories.
DIR_SCRIPT = sbin DIR_SCRIPT = bin
DIR_CONF = etc/restic DIR_CONF = etc/restic
DIR_SYSTEMD = usr/lib/systemd/system DIR_SYSTEMD = usr/lib/systemd/system
DIR_CRON = etc/cron.d DIR_CRON = etc/cron.d
+9 -9
View File
@@ -58,7 +58,7 @@ Depending on your system, the setup will look different. Choose one of
$ sudo make install-systemd $ sudo make install-systemd
``` ```
☝ **Note**: `sudo` is required here, as some files are installed into system directories (`/etc/` ☝ **Note**: `sudo` is required here, as some files are installed into system directories (`/etc/`
and `/usr/sbin`). Have a look to the `Makefile` to know more. and `/usr/bin`). Have a look to the `Makefile` to know more.
1. Fill out configuration values (edit with sudo): 1. Fill out configuration values (edit with sudo):
* `/etc/restic/pw.txt` - Contains the password (single line) to be used by restic to encrypt the repository files. Should be different than your B2 password! * `/etc/restic/pw.txt` - Contains the password (single line) to be used by restic to encrypt the repository files. Should be different than your B2 password!
* `/etc/restic/_global.env` - Global environment variables. * `/etc/restic/_global.env` - Global environment variables.
@@ -105,9 +105,9 @@ $ git clone https://github.com/erikw/restic-systemd-automatic-backup.git && cd $
$ sudo make install-systemd $ sudo make install-systemd
```` ````
If you want to install everything manually, we will install files to `/etc`, `/sbin`, and not use the `$make install-systemd` command, then you need to clean up a placeholder `$INSTALL_PREFIX` in the souce files first by running: If you want to install everything manually, we will install files to `/etc`, `/bin`, and not use the `$make install-systemd` command, then you need to clean up a placeholder `$INSTALL_PREFIX` in the souce files first by running:
```console ```console
$ find etc sbin -type f -exec sed -i.bak -e 's|$INSTALL_PREFIX||g' {} \; -exec rm {}.bak \; $ find etc bin -type f -exec sed -i.bak -e 's|$INSTALL_PREFIX||g' {} \; -exec rm {}.bak \;
``` ```
and you should now see that all files have been changed like e.g. and you should now see that all files have been changed like e.g.
```diff ```diff
@@ -152,7 +152,7 @@ $ restic init
``` ```
#### 4. Script for doing the backup #### 4. Script for doing the backup
Put this file in `/sbin`: Put this file in `/bin`:
* `restic_backup.sh`: A script that defines how to run the backup. The intention is that you should not need to edit this script yourself, but be able to control everything from the `*.env` profiles. * `restic_backup.sh`: A script that defines how to run the backup. The intention is that you should not need to edit this script yourself, but be able to control everything from the `*.env` profiles.
Restic support exclude files. They list file pattern paths to exclude from you backups, files that just occupy storage space, backup-time, network and money. `restic_backup.sh` allows for a few different exclude files. Restic support exclude files. They list file pattern paths to exclude from you backups, files that just occupy storage space, backup-time, network and money. `restic_backup.sh` allows for a few different exclude files.
@@ -165,7 +165,7 @@ Now see if the backup itself works, by running as root
```console ```console
$ sudo -i $ sudo -i
$ source /etc/restic/default.env $ source /etc/restic/default.env
$ /sbin/restic_backup.sh $ /bin/restic_backup.sh
```` ````
#### 6. Verify the backup #### 6. Verify the backup
@@ -229,7 +229,7 @@ $ journalctl -f -u restic-backup@default.service
#### 8. Email notification on failure #### 8. Email notification on failure
We want to be aware when the automatic backup fails, so we can fix it. Since my laptop does not run a mail server, I went for a solution to set up my laptop to be able to send emails with [postfix via my Gmail](https://easyengine.io/tutorials/linux/ubuntu-postfix-gmail-smtp/). Follow the instructions over there. We want to be aware when the automatic backup fails, so we can fix it. Since my laptop does not run a mail server, I went for a solution to set up my laptop to be able to send emails with [postfix via my Gmail](https://easyengine.io/tutorials/linux/ubuntu-postfix-gmail-smtp/). Follow the instructions over there.
Put this file in `/sbin`: Put this file in `/bin`:
* `systemd-email`: Sends email using sendmail(1). This script also features time-out for not spamming Gmail servers and getting my account blocked. * `systemd-email`: Sends email using sendmail(1). This script also features time-out for not spamming Gmail servers and getting my account blocked.
Put this files in `/etc/systemd/system/`: Put this files in `/etc/systemd/system/`:
@@ -241,7 +241,7 @@ As you maybe noticed already before, `restic-backup.service` is configured to st
#### 9. Optional: automated backup checks #### 9. Optional: automated backup checks
Once in a while it can be good to do a health check of the remote repository, to make sure it's not getting corrupt. This can be done with `$ restic check`. Once in a while it can be good to do a health check of the remote repository, to make sure it's not getting corrupt. This can be done with `$ restic check`.
There is companion scripts, service and timer (`*check*`) to restic-backup.sh that checks the restic backup for errors; look in the repo in `usr/lib/systemd/system/` and `sbin/` and copy what you need over to their corresponding locations. There is companion scripts, service and timer (`*check*`) to restic-backup.sh that checks the restic backup for errors; look in the repo in `usr/lib/systemd/system/` and `bin/` and copy what you need over to their corresponding locations.
```console ```console
$ sudo -i $ sudo -i
@@ -272,7 +272,7 @@ If you want to run an all-classic cron job instead, do like this:
1. Follow the main setup from [Step-by-step and manual setup](#step-by-step-and-manual-setup) but skip the systemd parts. 1. Follow the main setup from [Step-by-step and manual setup](#step-by-step-and-manual-setup) but skip the systemd parts.
1. `etc/cron.d/restic`: Depending on your system's cron, put this in `/etc/cron.d/` or similar, or copy the contents to $(sudo crontab -e). The format of this file is tested under FreeBSD, and might need adaptions depending on your cron. 1. `etc/cron.d/restic`: Depending on your system's cron, put this in `/etc/cron.d/` or similar, or copy the contents to $(sudo crontab -e). The format of this file is tested under FreeBSD, and might need adaptions depending on your cron.
* You can use `$ make install-cron` to copy it over to `/etc/cron.d`. * You can use `$ make install-cron` to copy it over to `/etc/cron.d`.
1. (Optional) `sbin/cron_mail`: A wrapper for running cron jobs, that sends output of the job as an email using the mail(1) command. 1. (Optional) `bin/cron_mail`: A wrapper for running cron jobs, that sends output of the job as an email using the mail(1) command.
# Uninstall # Uninstall
@@ -294,7 +294,7 @@ A list of variations of this setup:
* **Updating the `resticw` parser:** If you ever update the usage `DOC`, you will need to refresh the auto-generated parser: * **Updating the `resticw` parser:** If you ever update the usage `DOC`, you will need to refresh the auto-generated parser:
```console ```console
$ pip install doctopt.sh $ pip install doctopt.sh
$ doctopt.sh usr/local/sbin/resticw $ doctopt.sh usr/local/bin/resticw
``` ```
# Releasing # Releasing
+1 -1
View File
@@ -5,7 +5,7 @@
# Why? Because of FreeBSD the system cron uses sendmail, and I want to use ssmtp. # Why? Because of FreeBSD the system cron uses sendmail, and I want to use ssmtp.
# Make your crontab files like: # Make your crontab files like:
#SHELL=/bin/sh #SHELL=/bin/sh
#PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin #PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:$INSTALL_PREFIX/bin
#@daily root cron_mail freebsd-update cron #@daily root cron_mail freebsd-update cron
mail_target=root mail_target=root
View File
+1 -1
View File
@@ -1,5 +1,5 @@
SHELL=/bin/sh SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin/:$INSTALL_PREFIX/sbin/ PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin/:$INSTALL_PREFIX/bin/
# Order of crontab fields # Order of crontab fields
# minute hour mday month wday command # minute hour mday month wday command
# Reference: https://www.freebsd.org/doc/handbook/configtuning-cron.html # Reference: https://www.freebsd.org/doc/handbook/configtuning-cron.html
@@ -3,4 +3,4 @@ Description=Check if the current NetworkManager connection is metered
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=$INSTALL_PREFIX/sbin/nm-unmetered-connection.sh ExecStart=$INSTALL_PREFIX/bin/nm-unmetered-connection.sh
@@ -10,4 +10,4 @@ Nice=10
Environment="HOME=/root" Environment="HOME=/root"
# The random sleep (in seconds) is in the case of multiple backup profiles. Many restic instances started at the same time could case high load or network bandwith usage. # The random sleep (in seconds) is in the case of multiple backup profiles. Many restic instances started at the same time could case high load or network bandwith usage.
# `systemd-cat` allows showing the restic output to the systemd journal # `systemd-cat` allows showing the restic output to the systemd journal
ExecStart=bash -c 'sleep $(shuf -i 0-300 -n 1) && source $INSTALL_PREFIX/etc/restic/%I.env && $INSTALL_PREFIX/sbin/restic_backup.sh | systemd-cat' ExecStart=bash -c 'sleep $(shuf -i 0-300 -n 1) && source $INSTALL_PREFIX/etc/restic/%I.env && $INSTALL_PREFIX/bin/restic_backup.sh | systemd-cat'
+1 -1
View File
@@ -8,4 +8,4 @@ Requires=nm-unmetered-connection.service
Type=simple Type=simple
Nice=10 Nice=10
# `systemd-cat` allows showing the restic output to the systemd journal # `systemd-cat` allows showing the restic output to the systemd journal
ExecStart=bash -c 'source $INSTALL_PREFIX/etc/restic/%I.env && $INSTALL_PREFIX/sbin/restic_check.sh | systemd-cat' ExecStart=bash -c 'source $INSTALL_PREFIX/etc/restic/%I.env && $INSTALL_PREFIX/bin/restic_check.sh | systemd-cat'
@@ -6,6 +6,6 @@ Description=Send status email for %i to user
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=$INSTALL_PREFIX/sbin/systemd-email abc@gmail.com %i ExecStart=$INSTALL_PREFIX/bin/systemd-email abc@gmail.com %i
User=root User=root
Group=systemd-journal Group=systemd-journal