1
1
Fork 0
scripts/README.md

118 lines
2.6 KiB
Markdown
Raw Permalink Normal View History

# scripts
2020-10-21 23:05:08 +02:00
My personal collection of handy scripts. mostly bash.
2023-12-21 12:25:16 +01:00
| Name | Description |
| :--- | :---------- |
2023-12-21 12:37:45 +01:00
| [ci.sh](#cish) | A poor man's CI system |
| [restic-backup.sh](#restic-backupsh) | Simple wrapper script for [Restic](https://github.com/restic/restic) |
2020-06-22 09:19:15 +02:00
2023-12-21 12:25:16 +01:00
## ci.sh
2023-12-21 12:25:16 +01:00
### Install
Clone this repository anywhere on your system and link it into your `$PATH`.
```bash
sudo su; cd
git clone https://git.socialnerds.org/david/scripts.git
ln -s /root/scripts/ci.sh /usr/local/bin/ci
```
### Usage
2023-12-21 12:25:16 +01:00
```bash
Usage:
ci <options> <git-repo>
Options:
-s, --scripts <DIR> Specify the scripts directory (default: /root/ci-scripts)
-c, --checks <URL> Enable healthchecks.io integration
-n, --ntfy <URL> Enable ntfy.sh integration
-h, --help Print help screen and exit
-i, --info Print script information and exit
-v, --verbose More verbose output
-q, --quiet No output except errors (overrides -v)
```
## restic-backup.sh
2021-02-10 19:07:59 +01:00
> This script is my very simple take on how to perform restic backups.
2018-05-13 19:36:41 +02:00
2023-10-28 20:10:53 +02:00
### Install
2020-10-21 23:05:08 +02:00
```bash
2021-02-10 19:07:59 +01:00
# Download
2023-10-28 20:10:53 +02:00
sudo su; cd
git clone https://git.socialnerds.org/david/scripts.git
ln -s /root/scripts/restic-backup.sh /usr/local/bin/restic-backup
2018-05-13 19:36:41 +02:00
```
2020-10-21 23:05:08 +02:00
2023-10-28 20:10:53 +02:00
2018-05-13 19:36:41 +02:00
2021-02-10 19:07:59 +01:00
```bash
# **** CONFIG ****
PASSWORD="/root/.restic-password"
REPO="sftp:<remote-server>:/path/to/repository"
KEEP=30
BIN="/usr/bin/restic"
2021-02-10 19:07:59 +01:00
OPTIONS="-p $PASSWORD -r $REPO -q"
```
You can run `restic_backup.sh` directly from the command line
2020-10-21 23:05:08 +02:00
2021-02-10 19:07:59 +01:00
```bash
# Usage
/root/restic_backup.sh /local/path <additional flags for the backup subcommand>
2020-10-21 23:05:08 +02:00
2021-02-10 19:07:59 +01:00
# Example
/root/restic_backup.sh /home -x -e ./.snapshots
```
2020-10-21 23:05:08 +02:00
2021-02-10 19:07:59 +01:00
or using cron.
```bash
# Cronjob
47 0 * * * /root/restic_backup.sh /home
# Cronjob (with healthchecks notification)
47 0 * * * /root/restic_backup.sh /home && curl -fsS -m 10 --retry 5 -o /dev/null https://checks.socialnerds.org/ping/fb721aec-5179-42c3-3455-4fd2ff39ii55
```
Happy backuping! :-)
## restic-repos.sh
## btrfs-snapshots.sh
## odroid-fancontrol.sh
## lib.sh
## template.sh
Use this as a base for new scripts, it already has the essentials.
```sh
# Load lib.sh
SCRIPT_LIB="lib.sh"
SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
if [[ -r "$SCRIPT_DIR/$SCRIPT_LIB" ]]; then
source "$SCRIPT_DIR/$SCRIPT_LIB"
lib_print "Loading version $LIB_GREEN_BOLD$LIB_VERSION$LIB_CLEAR of $LIB_GREEN_BOLD$LIB_NAME$LIB_CLEAR"
else
echo "Error: Cannot load library file [$SCRIPT_DIR/$SCRIPT_LIB]"
exit 1
fi
```
-----
## watch-containers.sh
Simple healthchecks script to monitor running containers.
## switch-desktop.sh
I think this is only useful with ElementaryOS. I use(d) this with a hot corner to control desktops with the mouse.