diff options
| author | 2024-01-07 21:06:01 +0000 | |
|---|---|---|
| committer | 2024-01-07 21:06:01 +0000 | |
| commit | 22cb139d5b320a5c7701d89b7ff1f31d13c00931 (patch) | |
| tree | 54e356aba5735ab2b8dc1bef57fc961fcd6c932d | |
| parent | Updated RELEASE_NOTES. (diff) | |
| parent | Addes NetBSD rc script example (diff) | |
| download | snac2-22cb139d5b320a5c7701d89b7ff1f31d13c00931.tar.gz snac2-22cb139d5b320a5c7701d89b7ff1f31d13c00931.tar.xz snac2-22cb139d5b320a5c7701d89b7ff1f31d13c00931.zip | |
Merge pull request 'Added compatibility with NetBSD' (#99) from draga79/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/99
Diffstat (limited to '')
| -rw-r--r-- | Makefile.NetBSD | 59 | ||||
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | examples/snac_netbsd | 34 |
3 files changed, 102 insertions, 1 deletions
diff --git a/Makefile.NetBSD b/Makefile.NetBSD new file mode 100644 index 0000000..2d1194d --- /dev/null +++ b/Makefile.NetBSD | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | PREFIX=/usr/pkg | ||
| 2 | PREFIX_MAN=$(PREFIX)/man | ||
| 3 | CFLAGS?=-g -Wall -Wextra | ||
| 4 | |||
| 5 | all: snac | ||
| 6 | |||
| 7 | snac: snac.o main.o data.o http.o httpd.o webfinger.o \ | ||
| 8 | activitypub.o html.o utils.o format.o upgrade.o mastoapi.o | ||
| 9 | $(CC) $(CFLAGS) -L/usr/pkg/lib *.o -lcurl -lcrypto -pthread $(LDFLAGS) -Wl,-rpath,/usr/lib -Wl,-rpath,/usr/pkg/lib -o $@ | ||
| 10 | |||
| 11 | |||
| 12 | .c.o: | ||
| 13 | $(CC) $(CFLAGS) $(CPPFLAGS) -I/usr/pkg/include -c $< | ||
| 14 | |||
| 15 | clean: | ||
| 16 | rm -rf *.o *.core snac makefile.depend | ||
| 17 | |||
| 18 | dep: | ||
| 19 | $(CC) -I/usr/pkg/include -MM *.c > makefile.depend | ||
| 20 | |||
| 21 | install: | ||
| 22 | mkdir -p -m 755 $(PREFIX)/bin | ||
| 23 | install -m 755 snac $(PREFIX)/bin/snac | ||
| 24 | mkdir -p -m 755 $(PREFIX_MAN)/man1 | ||
| 25 | install -m 644 doc/snac.1 $(PREFIX_MAN)/man1/snac.1 | ||
| 26 | mkdir -p -m 755 $(PREFIX_MAN)/man5 | ||
| 27 | install -m 644 doc/snac.5 $(PREFIX_MAN)/man5/snac.5 | ||
| 28 | mkdir -p -m 755 $(PREFIX_MAN)/man8 | ||
| 29 | install -m 644 doc/snac.8 $(PREFIX_MAN)/man8/snac.8 | ||
| 30 | |||
| 31 | uninstall: | ||
| 32 | rm $(PREFIX)/bin/snac | ||
| 33 | rm $(PREFIX_MAN)/man1/snac.1 | ||
| 34 | rm $(PREFIX_MAN)/man5/snac.5 | ||
| 35 | rm $(PREFIX_MAN)/man8/snac.8 | ||
| 36 | |||
| 37 | activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_mime.h \ | ||
| 38 | xs_openssl.h xs_regex.h xs_time.h xs_set.h xs_match.h snac.h | ||
| 39 | data.o: data.c xs.h xs_hex.h xs_io.h xs_json.h xs_openssl.h xs_glob.h \ | ||
| 40 | xs_set.h xs_time.h snac.h | ||
| 41 | format.o: format.c xs.h xs_regex.h xs_mime.h xs_html.h snac.h | ||
| 42 | html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \ | ||
| 43 | xs_time.h xs_mime.h xs_match.h xs_html.h snac.h | ||
| 44 | http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \ | ||
| 45 | snac.h | ||
| 46 | httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_httpd.h xs_mime.h \ | ||
| 47 | xs_time.h xs_openssl.h xs_fcgi.h xs_html.h snac.h | ||
| 48 | main.o: main.c xs.h xs_io.h xs_json.h snac.h xs_html.h | ||
| 49 | mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ | ||
| 50 | xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ | ||
| 51 | snac.h | ||
| 52 | snac.o: snac.c xs.h xs_hex.h xs_io.h xs_unicode.h xs_json.h xs_curl.h \ | ||
| 53 | xs_openssl.h xs_socket.h xs_url.h xs_httpd.h xs_mime.h xs_regex.h \ | ||
| 54 | xs_set.h xs_time.h xs_glob.h xs_random.h xs_match.h xs_fcgi.h xs_html.h \ | ||
| 55 | snac.h | ||
| 56 | upgrade.o: upgrade.c xs.h xs_io.h xs_json.h xs_glob.h snac.h | ||
| 57 | utils.o: utils.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h \ | ||
| 58 | xs_random.h xs_glob.h snac.h | ||
| 59 | webfinger.o: webfinger.c xs.h xs_json.h xs_curl.h xs_mime.h snac.h \ No newline at end of file | ||
| @@ -46,9 +46,17 @@ On FreeBSD, to install `curl` just type: | |||
| 46 | pkg install curl | 46 | pkg install curl |
| 47 | ``` | 47 | ``` |
| 48 | 48 | ||
| 49 | On NetBSD, to install `curl` just type: | ||
| 50 | |||
| 51 | ```sh | ||
| 52 | pkgin install curl | ||
| 53 | ``` | ||
| 54 | |||
| 49 | The source code is available [here](https://comam.es/what-is-snac). | 55 | The source code is available [here](https://comam.es/what-is-snac). |
| 50 | 56 | ||
| 51 | Run `make` and then `make install` as root. | 57 | Run `make` and then `make install` as root. |
| 58 | |||
| 59 | If you're compiling on NetBSD, you should use the specific provided Makefile and run `make -f Makefile.NetBSD` and then `make -f Makefile.NetBSD install` as root. | ||
| 52 | 60 | ||
| 53 | From version 2.27, `snac` includes support for the Mastodon API; if you are not interested on it, you can compile it out by running | 61 | From version 2.27, `snac` includes support for the Mastodon API; if you are not interested on it, you can compile it out by running |
| 54 | 62 | ||
diff --git a/examples/snac_netbsd b/examples/snac_netbsd new file mode 100644 index 0000000..06991b1 --- /dev/null +++ b/examples/snac_netbsd | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # PROVIDE: snac | ||
| 4 | # REQUIRE: DAEMON | ||
| 5 | # KEYWORD: shutdown | ||
| 6 | |||
| 7 | . /etc/rc.subr | ||
| 8 | |||
| 9 | name="snac" | ||
| 10 | rcvar=${name} | ||
| 11 | command="/usr/pkg/bin/snac" | ||
| 12 | command_args="httpd /PATH/TO/SNACDATA" | ||
| 13 | snac_log="/var/log/snac.log" | ||
| 14 | pidfile="/var/run/${name}/${name}.pid" | ||
| 15 | start_precmd="snac_precmd" | ||
| 16 | run_as_user="SNACUSER" | ||
| 17 | |||
| 18 | snac_precmd() { | ||
| 19 | # Ensure log file exists and is writable by SNACUSER | ||
| 20 | touch ${snac_log} | ||
| 21 | chown ${run_as_user} ${snac_log} | ||
| 22 | chmod 640 ${snac_log} | ||
| 23 | |||
| 24 | # Ensure the run directory exists | ||
| 25 | if [ ! -d /var/run/${name} ]; then | ||
| 26 | mkdir -p /var/run/${name} | ||
| 27 | chown ${run_as_user} /var/run/${name} | ||
| 28 | fi | ||
| 29 | |||
| 30 | command="/bin/sh -c 'cd /var/run/${name}; exec ${command} ${command_args} >${snac_log} 2>&1 & echo \$! >${pidfile}'" | ||
| 31 | } | ||
| 32 | |||
| 33 | load_rc_config $name | ||
| 34 | run_rc_command "$1" \ No newline at end of file | ||