Skip to content

Commit 39c2bbc

Browse files
add and change various info
1 parent 03c67e8 commit 39c2bbc

File tree

2 files changed

+45
-28
lines changed

2 files changed

+45
-28
lines changed

README.md

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
# werc-on-openbsd
1+
werc-on-openbsd
2+
===============
23

34
Automate [Werc](http://werc.cat-v.org/) setup on [OpenBSD](https://www.openbsd.org/).
45

56
## Useful info
67

7-
<!--
8-
Both the `setup.sh` and `unsetup.sh` scripts, in their latest available version ([v1.3](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v1.3)), have been successfully tested on the latest available OpenBSD stable release (7.6). Prior or later versions of OpenBSD may not work.
9-
-->
8+
Both the `setup.sh` and `unsetup.sh` scripts, in their latest available version ([v2.0](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v2.0)), have been successfully tested on the latest available OpenBSD stable release (7.6). Prior or later versions of OpenBSD may not work.
109

11-
**Performing an OpenBSD release upgrade (e.g. by using [sysupgrade(8)](https://man.openbsd.org/sysupgrade.8)) or updating the `plan9port` package may break the current Werc installation.** It is advised to always test your Werc installation after performing either a system upgrade or a `plan9port` update. If it stops working, head to [Troubleshooting](#troubleshooting).
10+
**Performing an OpenBSD release upgrade (e.g. by using [sysupgrade(8)](https://man.openbsd.org/sysupgrade.8)) may break the current Werc installation.** It is advised to always test your Werc installation after performing either a system upgrade, a Werc update, or a plan9port update. If it stops working, head to [Troubleshooting](#troubleshooting).
1211

1312
### Limitations
1413

15-
For now, the installation (resulting from `setup.sh`) has only been tested with `GET` requests, which it supports for sure. Other types of HTTP requests may or may not work. The URL-based rules in `/etc/httpd.conf` may need a different configuration to support other HTTP requests as well.
14+
For now, the installation resulting from `setup.sh` has only been tested with `GET` requests, which it supports for sure. Other types of HTTP requests may or may not work (e.g. the "user login" feature). The URL-based rules in `/etc/httpd.conf` (`location ...`) may need a different configuration to support HTTP requests other than `GET`.
1615

1716
### Other info
1817

@@ -35,9 +34,9 @@ Since the testing process is manual I may overlook some edge cases, sometimes on
3534

3635
In the following list, `$webdir` and `$p9pdir` respectively refer to `httpd`'s web content directory, by default `/var/www`, and plan9port's installation directory with `$webdir` as root, by default `/plan9`.
3736

38-
- **Do the files `/etc/httpd.conf.bk` and `/etc/fstab.bk` already exist in your machine's file system?** If so, `setup.sh` will overwrite them, consider renaming or removing them.
39-
- **Did you add or change files in `$webdir` which cannot be lost?** The setup script creates new files in `$webdir` which may overwrite existing ones while the unsetup script removes some directories which may delete those files. Consider moving important files out of `$webdir` or placing them in directories which will not be removed.
40-
- **Did you make a backup of your machine?** The setup script may fail to complete, for example due to a network error. This leads to an incomplete installation and neither running `setup.sh` again, nor running `unsetup.sh`, is going to repair it. Depending on which command(s) failed and the type of error, you may be able to manually repair the installation by yourself. However, this is not always the case and it's an error-prone procedure, so it's discouraged.
37+
- **Do the files `/etc/httpd.conf.bk` and `/etc/fstab.bk` already exist in your machine's file system?** If so, `setup.sh` will probably overwrite them, consider renaming or removing them.
38+
- **Did you add or change files in `$webdir` which cannot be lost?** The setup script creates new files in `$webdir` which may overwrite existing ones while the unsetup script removes some directories which may delete those files. Consider moving important files out of `$webdir`.
39+
- **Did you make a backup of your machine?** The setup script may fail to complete, for example due to a network error. This leads to an incomplete installation and neither running `setup.sh` again, nor running `unsetup.sh`, is going to repair it. (If it did, you're just lucky.) Depending on which command(s) failed and the type of error, you may be able to manually repair the installation by yourself. However, this is not always the case and it's an error-prone procedure, so it is not advised at all.
4140

4241
### Actual usage
4342

@@ -48,52 +47,70 @@ The following procedure refers to the setup script (`setup.sh`). For the un-setu
4847
The procedure is as follows, written both in human-readable steps and as commands:
4948

5049
1. Download the script from the latest tag.
51-
2. Verify the script's checksum (see [Checksums](#checksums)).
50+
2. Verify the script's checksum (see [checksums](#sha-256-checksums-v20)).
5251
3. Change the `domain` variable (and `webdir`, if necessary) at will.
5352
4. Set the execution permission bit of the script.
5453
5. Start the script as root.
5554

5655
```sh
57-
ftp https://raw.githubusercontent.com/EdoardoLaGreca/werc-on-openbsd/v1.2/setup.sh
56+
ftp https://raw.githubusercontent.com/EdoardoLaGreca/werc-on-openbsd/v2.0/setup.sh
5857
sha256 -q setup.sh
5958
vi setup.sh # change domain and webdir
6059
chmod 744 setup.sh
6160
doas ./setup.sh
6261
```
6362

64-
The `setup.sh` script does not automatically start `httpd` and `slowcgi`. It behaves like that for two reasons: firstly you might want to make some final changes to your website before displaying it publicly and secondly you may have to reboot your system before starting the webserver if `/etc/fstab` has been changed by the script. The script should display a log message if you need to reboot (and/or `/etc/fstab` has been changed). The absence of such message in the log means that rebooting is not necessary. This does not apply to `unsetup.sh`.
63+
The setup script does not automatically start `httpd` and `slowcgi`. It behaves like that for two reasons: firstly, you might want to make some final changes to your website before displaying it publicly; secondly, if `/etc/fstab` has been changed by the script, you need to reboot your system before starting the webserver. The script should display a log message if you need to reboot (and/or `/etc/fstab` has been changed). The absence of such message in the log means that rebooting is not necessary. All this does not apply to `unsetup.sh`.
6564

66-
### Running parts
65+
#### Running parts
6766

68-
Instead of running the entire script, one might want to run just one or some parts to, for example, debug the script or run again a part which could not terminate successfully. To do so is as simple as passing the function names to the script as arguments. An example is shown below.
67+
Instead of running the entire script, one might want to run just one or some parts to, for example, debug the script or run again a part which could not terminate successfully. To do so is as simple as passing the part names to the script as arguments. An example is shown below.
6968

7069
```sh
7170
./setup.sh preinst inst
7271
```
7372

74-
Although the example above uses `setup.sh`, `unsetup.sh` also behaves in this way.
73+
Although the line above uses `setup.sh`, `unsetup.sh` also behaves in this way.
7574

76-
## Troubleshooting
75+
### Maintenance
7776

78-
### Werc stops working after upgrading OpenBSD or updating plan9port
77+
It is good practice to keep software up to date, both to receive new features and to patch existing vulnerabilities.
7978

80-
It may happen that, after upgrading OpenBSD or updating the `plan9port` package, your website stops working and only shows "500 internal server error".
79+
When using Werc, 4 pieces of software need to be kept up to date:
8180

82-
I don't know the reason, if I'm being honest. However, I found out that removing all the contents of the `plan9port` package from the webserver's directory and then placing them there again solves the error. Uninstalling and re-installing everything would work, although this solution is a waste of time, especially on slower machines, and could potentially have some side effects (it is not guaranteed not to have them).
81+
- OpenBSD's own HTTP and SlowCGI daemons (a.k.a. `httpd` and `slowcgi`)
82+
- Werc
83+
- plan9port
8384

84-
The proper way to solve this issue is by using the following commands.
85+
Unless you're using OpenBSD's `-current` branch, `httpd` and `slowcgi` are usually updated on every system upgrade. They are pretty secure and minimalist so keeping them up to date is not essential. These programs are part of OpenBSD's source tree which contains the whole operating system, including its kernel, essential libraries, and all preinstalled utilities. All software in that source tree undergoes severe security audits, that's why they are so secure.
8586

87+
On the other hand, it's important to keep Werc and plan9port up to date. To do so, run the following lines in the shell. They remove the existing Werc and plan9port installations, download their updated version, and install them again.
88+
89+
```sh
90+
doas ./unsetup.sh uninst rm9env
91+
doas ./setup.sh inst mk9env
8692
```
87-
doas ./unsetup.sh rm9env
88-
doas ./setup.sh mk9env
89-
```
9093

91-
## Checksums (v1.3)
94+
## Troubleshooting
95+
96+
### Werc stops working after upgrading OpenBSD
97+
98+
It may happen that, after upgrading OpenBSD, your website stops working and only shows "500 internal server error".
9299

93-
`setup.sh` SHA-256: ``
100+
While the exact reason behind this behavior should be carefully analyzed and understood, you might try uninstalling and re-installing Werc and plan9port. The procedure is the same as if you were to update them.
94101

95-
`unsetup.sh` SHA-256: ``
102+
```sh
103+
doas ./unsetup.sh uninst rm9env
104+
doas ./setup.sh inst mk9env
105+
```
106+
107+
## SHA-256 checksums (v2.0)
108+
109+
```
110+
0eb42f6f27a32fa15b61616279d3d474779ea83e62d5477e66d25b8170d27d58 setup.sh
111+
18f74da2537dc4dcc97c3fc6d4439faf6340f068309d9110a5dc098b899c3e50 unsetup.sh
112+
```
96113

97114
## License
98115

99-
Starting from [v1.3](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v1.3) the project is now licensed under the ISC license, instead of Creative Commons Zero. Most things don't change, except for giving users and contributors more rights.
116+
Starting from [v2.0](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v2.0) the project is now licensed under the ISC license, instead of Creative Commons Zero. Most things don't change, except for giving users and contributors more rights.

rat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ Another thing I really cared about, back when I started writing this script, is
1616

1717
In addition to all I said before, and this was by far the hardest goal to achieve, all this had to comply with OpenBSD's [httpd](https://man.openbsd.org/httpd) way of doing things. That is, the hosted website is served from a `chroot`'ed directory, `/var/www`. By doing so, potential breaches are only limited to that portion of the file system. At first, since [symlinks](https://en.wikipedia.org/wiki/Symbolic_link) cannot be accessed from a `chroot`'ed environment, I solved it the naïve way: I just copied all the Plan 9 utilities, together with their shared objects, into `/var/www`. This was not the best solution, not even close, but it worked for a while. Then, I switched to [hard links](https://en.wikipedia.org/wiki/Hard_link). In theory, hard links consume way less data on disk. In practice, most of the times they are not possible because even OpenBSD's default installation splits the filesystem into many partitions and hard links cannot be created from one disk/partition to the other. At that time I wrote the setup script to only hard link files when possible and to copy them otherwise. Given the probabilities of finding an OpenBSD installation with all files on the same partition, this latter solution was basically the same as the former, naïve solution.
1818

19-
The final solution, introduced in [v1.3](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v1.3), is to clone plan9port's git repository into the `chroot`'ed filesystem and install it there, with its hard-coded paths adjusted through the `-r` option. Not only this improves the system's security, since patches can be applied immedately, but it also eliminates the need of work-arounds to make hard-coded paths work.
19+
The final solution, introduced in [v2.0](https://github.com/EdoardoLaGreca/werc-on-openbsd/releases/tag/v2.0), is to clone plan9port's git repository into the `chroot`'ed filesystem and install it there, with its hard-coded paths adjusted through the `-r` option. Not only this improves the system's security, since patches can be applied immedately, but it also eliminates the need of work-arounds to make hard-coded paths work.

0 commit comments

Comments
 (0)