Skip to content

Commit 4776073

Browse files
Merge remote-tracking branch 'origin/main' into add-btidy
2 parents bae131e + bd6d41f commit 4776073

File tree

3 files changed

+229
-14
lines changed

3 files changed

+229
-14
lines changed

README.md

Lines changed: 220 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,229 @@
1-
Obscure Scripts
2-
===============
1+
# Obscure Scripts
32

43
A collection of scripts from [The Obscure Organization](https://www.obscure.org) - a public access UNIX system in continuous use since 1995.
54

6-
* [blockip.sh](blockip.sh) - Use iptables to temporarily block an IP addreess or CIDR block
7-
* [btidy.sh](btidy.sh) - Use [HTML tidy](https://www.html-tidy.org/) but <em>only versus the body</em> of an HTML file. Useful for cleaning up fragments of HTML files, or for using as a filter in vim (`:'a,'b ! btidy -wrap 0 -i -asxml`)
8-
* [cloud-init-centos-7-ipv6.yml](cloud-init-centos-7-ipv6.yml) - Use in instance data for CentOS 7.x EC2 servers that are having trouble getting an IPv6 default route. See also
9-
[cloud-init-centos-7.6-ipv4-ena.yml](cloud-init-centos-7.6-ipv4-ena.yml) and [cloud-init-centos-7.6-ipv6-ena.yml](cloud-init-centos-7.6-ipv4-ena.yml)
10-
* [icinga2-graceful.sh](icinga2-graceful.sh) - Check the validity of icinga2 system configuration files, then restart it only if the configuration is ok.
11-
* [icinga2-watchdog.sh](icinga2-watchdog.sh) - Ensure that an icinga2 system alerts once per day to let people know it is still alive - and where to complain if it is dead.
12-
* [imapd-reap-processes.sh](imapd-reap-processes.sh) - Kill off stale imapd processes that accumulate on a busy mail server
13-
* [patronus.sh](patronus.sh) - kill login sessions and processes on other ttys, with a whimsical Harry Potter twist. This might be one of the only works of fan fiction parody written in `bash`!. Originally [released under the GPLv3](https://obscurerichard.wordpress.com/2007/09/06/harry-potter-shell-script-fan-fiction-in-celebration-of-my-35th-birthday/), now relicensed under the MIT license, and updated to be shellcheck clean.
14-
* [run-sysbench.sh](run-sysbench.sh) - Run [sysbench](https://github.com/akopytov/sysbench) with a standard set of options. Useful for collecting the same set of performance statistics on multiple hosts.
15-
* [ssh-add-all.sh](ssh-add-ramdisk.sh) - Alias to add all your SSH keys from $HOME/.ssh/ with one command.
5+
## blockip.sh
6+
7+
[blockip.sh](blockip.sh) - Use iptables to temporarily block an IP addreess or CIDR block
8+
9+
### Description
10+
This script uses iptables to temporarily block an IP address or CIDR block. It can be useful for mitigating unwanted traffic or attacks.
11+
12+
### Usage
13+
```sh
14+
./blockip.sh 192.2.0.0
15+
./blockip.sh 192.2.0.1 now+1day
16+
```
17+
Symlink this into /usr/local/sbin to use it system-wide. To run with debugging information enabled:
18+
```sh
19+
DEBUG=true /usr/local/sbin/blockip.sh
20+
```
21+
22+
## btidy.sh
23+
24+
[btidy.sh](btidy.sh) - Use [HTML tidy](https://www.html-tidy.org/) but only versus the body of an HTML file. Useful for filtering fragments of HTML files, or for using in vim (`:'a,'b ! btidy -wrap 0 -i -asxml`)
25+
26+
### Description
27+
This script uses HTML tidy to clean up the body of an HTML file. It is useful for filtering fragments of HTML files or for use in vim.
28+
29+
### Usage
30+
```sh
31+
./btidy.sh <filename> [options] ...
32+
```
33+
From vi family editors, assuming btidy.sh is in your path:
34+
```sh
35+
:% ! btidy.sh [options]
36+
:'a,'b ! btidy.sh -i
37+
```
38+
39+
## cloud-init-centos-7-ipv6.yml
40+
41+
[cloud-init-centos-7-ipv6.yml](cloud-init-centos-7-ipv6.yml) - Use in instance data for CentOS 7.x EC2 servers that are having trouble getting an IPv6 default route. See also [cloud-init-centos-7.6-ipv4-ena.yml](cloud-init-centos-7.6-ipv4-ena.yml) and [cloud-init-centos-7.6-ipv6-ena.yml](cloud-init-centos-7.6-ipv4-ena.yml)
42+
43+
### Description
44+
This cloud-init configuration is intended for older CentOS 7.x EC2 instances that are having trouble getting an IPv6 default route. It includes specific configurations for the ENA adapter and other settings.
45+
46+
### Usage
47+
Use this file as instance data when launching or configuring CentOS 7.x EC2 instances.
48+
49+
## icinga2-graceful.sh
50+
51+
[icinga2-graceful.sh](icinga2-graceful.sh) - Check the validity of icinga2 system configuration files, then restart it only if the configuration is ok.
52+
53+
### Description
54+
This script validates the icinga2 configuration and restarts the service only if the configuration is valid. It helps prevent service disruptions due to invalid configurations.
55+
56+
### Usage
57+
```sh
58+
./icinga2-graceful.sh
59+
```
60+
To run with debugging information enabled:
61+
```sh
62+
DEBUG=true ./icinga2-graceful.sh
63+
```
64+
65+
## icinga2-watchdog.sh
66+
67+
[icinga2-watchdog.sh](icinga2-watchdog.sh) - Ensure that an icinga2 system alerts once per day to let people know it is still alive - and where to complain if it is dead.
68+
69+
### Description
70+
This script ensures that an icinga2 system sends a custom notification every day to remind you that it is still alive. It helps monitor the health of the icinga2 system.
71+
72+
### Usage
73+
Configure an API user called "watchdog" in /etc/icinga2/conf.d/api-users.conf:
74+
```sh
75+
object ApiUser "watchdog" {
76+
password = "replace-me-with-a-real-password"
77+
permissions = [ "*" ]
78+
}
79+
```
80+
Set up a host group in your conf.d/host-groups.conf:
81+
```sh
82+
object HostGroup "icinga-servers" {
83+
display_name = "Icinga Servers"
84+
assign where host.vars.icinga
85+
}
86+
```
87+
Create a configuration file to customize the message and credentials, and put it in /etc/icinga2/icinga2-watchdog.env:
88+
```sh
89+
CREDENTIALS='watchdog:xxxxxxxxxxxxxyyyyyyyyyyyzzzzzz12'
90+
CONTACT_NAME='Snafu Fubar'
91+
CONTACT_PHONE='+1 555 555 1212'
92+
```
93+
Add a crontab entry on your icinga server:
94+
```sh
95+
0 16 * * * set -a && . /etc/icinga2/icinga2-watchdog.env && /usr/local/bin/icinga2-watchdog.sh
96+
```
97+
98+
## imapd-reap-processes.sh
99+
100+
[imapd-reap-processes.sh](imapd-reap-processes.sh) - Kill off stale imapd processes that accumulate on a busy mail server
101+
102+
### Description
103+
This script purges root-owned imapd processes that started and never got killed off. It helps save process slots and memory on a busy mail server.
104+
105+
### Usage
106+
Create symlinks to activate this:
107+
```sh
108+
sudo ln -s $(pwd)/imapd-reap-processes.sh /usr/local/sbin/imapd-reap-processes.sh
109+
sudo ln -s /usr/local/sbin/imapd-reap-processes.sh /etc/cron.daily/imapd-reap-processes
110+
```
111+
112+
## patronus.sh
113+
114+
[patronus.sh](patronus.sh) - kill login sessions and processes on other ttys, with a whimsical magic twist.
115+
116+
### Description
117+
This script kills login sessions and processes on other ttys the way Harry Potter would have done it. It is a parody of J.K. Rowling's novels; this is perhaps one of the only works of fan fiction _or_ parody written in `bash`!. Originally [released under the GPLv3](https://obscurerichard.wordpress.com/2007/09/06/harry-potter-shell-script-fan-fiction-in-celebration-of-my-35th-birthday/), now relicensed under the MIT license, and updated to be [shellcheck clean](https://shellcheck.net).
118+
119+
### Usage
120+
```sh
121+
./patronus.sh
122+
```
123+
To run with debugging information enabled:
124+
```sh
125+
DEBUG=true ./patronus.sh
126+
```
127+
128+
## run-sysbench.sh
129+
130+
[run-sysbench.sh](run-sysbench.sh) - Run [sysbench](https://github.com/akopytov/sysbench) with a standard set of options. Useful for collecting the same set of performance statistics on multiple hosts.
131+
132+
### Description
133+
This script runs a complete suite of sysbench performance benchmarks. It is useful for collecting the same set of performance statistics on multiple hosts.
134+
135+
### Usage
136+
```sh
137+
./run-sysbench.sh <storage_type>
138+
```
139+
Replace `<storage_type>` with either `disk` or `ssd`.
140+
141+
## ssh-add-all.sh
142+
143+
[ssh-add-all.sh](ssh-add-ramdisk.sh) - Alias to add all your SSH keys from $HOME/.ssh/ with one command.
144+
145+
### Description
146+
This script adds all your SSH keys from $HOME/.ssh/ with one command. It is useful for quickly adding multiple SSH keys to the SSH agent.
147+
148+
### Usage
149+
```sh
150+
./ssh-add-all.sh
151+
```
152+
153+
## ssh-add-ramdisk.sh
154+
16155
* [ssh-add-ramdisk.sh](ssh-add-ramdisk.sh) - Keep your SSH keys on a USB key, but load them into a RAMDisk on macOS or Linux - so you don't have to keep permanent copies of the SSH keys on the systems you physically use, which is useful sometimes.
156+
157+
### Description
158+
This script allows you to copy your SSH keys from removable media to a RAM disk and then adds the SSH keys to your current SSH agent keyring. It is useful for keeping your SSH keys secure and not leaving permanent copies on the systems you use.
159+
160+
### Usage
161+
```sh
162+
./ssh-add-ramdisk.sh
163+
```
164+
To remove the ramdisk:
165+
```sh
166+
./ssh-add-ramdisk.sh -r
167+
```
168+
169+
## ssh-env.sh
170+
17171
* [ssh-env.sh](ssh-env.sh) - Use to help reconnect managed terminal sessions (think `screen` or `tmux`) terminals to your SSH key agent via environment manipulation.
172+
173+
### Description
174+
This script helps propagate the SSH environment inside the current session. It is useful for reconnecting managed terminal sessions (e.g., `screen` or `tmux`) to your SSH key agent.
175+
176+
### Usage
177+
```sh
178+
./ssh-env.sh
179+
```
180+
Inside your .profile, .bash_profile, or .bash_login:
181+
```sh
182+
./ssh-env.sh
183+
```
184+
When running interactively in a tmux or screen session, include the output of ssh-env.sh and regain access to your SSH agent:
185+
```sh
186+
. ~/.ssh/env
187+
```
188+
189+
## uptimerobot-firewall-update.sh
190+
18191
* [uptimerobot-firewall-update.sh](uptimerobot-firewall-update.sh) - Update firewall entries that allow [uptimerobot.com](https://www.uptimerobot.com/) to check otherwise resticted services. Uptime Robot is free and is suitable for small-scale monitoring as a primary service or as a secondary monitor that watches your primary monitoring system and most critical services.
19-
* [tiamat-setup.sh](tiamat-setup.sh) - Set up packages and more on tiamat.obscure.org (emergency recovery script)
20-
* [watch-filevault-setup.sh](wuhatch-filevault-setup.sh) - Watch and log the filevault encryption process, which can take a really long time on an older Macintosh.
192+
193+
### Description
194+
This script updates the firewall entries to allow uptimerobot.com to check otherwise restricted services. It is useful for integrating Uptime Robot with your monitoring setup.
195+
196+
### Usage
197+
Run this on a host that will be monitored through uptimerobot.com. Consider linking it into cron, for example:
198+
```sh
199+
sudo ln -s $PWD/uptimerobot-firewall-update.sh /etc/cron.weekly/
200+
```
201+
202+
## tiamat-setup.sh
203+
204+
[tiamat-setup.sh](tiamat-setup.sh) - Set up packages and more on tiamat.obscure.org (emergency recovery script)
205+
206+
### Description
207+
This script sets up packages and more on `tiamat.obscure.org`, the main server for [The Obscure Organization](https://www.obscure.org/). It is an emergency recovery script for setting up the system after catastrophic failures, and also gets used to install packages and configure the system on an intermittent basis.
208+
209+
### Usage
210+
Run this script as root to set up the necessary packages and configurations on `tiamat.obscure.org`.
211+
212+
```sh
213+
sudo ./tiamat-setup.sh
214+
```
215+
216+
## watch-filevault-setup.sh
217+
218+
* [watch-filevault-setup.sh](watch-filevault-setup.sh) - Watch and log the filevault encryption process, which can take a really long time on an older Macintosh.
219+
220+
### Description
221+
This script watches the progress of FileVault and logs the progress to a file. It is useful for monitoring the FileVault encryption process on macOS.
222+
223+
### Usage
224+
```sh
225+
./watch-filevault-setup.sh
226+
```
21227

22228
Acknowledgements
23229
----------------

cert-notifier.sh

100755100644
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
# restart those subsystems.
66
#
77
# Configure this in /etc/sysconfig/certbot
8+
#
9+
# Copyright (C) 2022 The Obscure Organization
10+
#
11+
# MIT licensed. See the LICENSE file for details.
812

913
# Set unofficial bash strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
1014
set -euo pipefail

mail-symlink-inbox.sh

100755100644
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bash
22
# mail-symlink-inbox.sh
3+
#
4+
# Copyright (C) 2022 The Obscure Organization
5+
#
6+
# MIT licensed. See the LICENSE file for details.
7+
38
set -euo pipefail
49

510
DEBUG=${DEBUG:-false}

0 commit comments

Comments
 (0)