summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar grunfink2024-01-07 21:06:01 +0000
committerGravatar grunfink2024-01-07 21:06:01 +0000
commit22cb139d5b320a5c7701d89b7ff1f31d13c00931 (patch)
tree54e356aba5735ab2b8dc1bef57fc961fcd6c932d
parentUpdated RELEASE_NOTES. (diff)
parentAddes NetBSD rc script example (diff)
downloadsnac2-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.NetBSD59
-rw-r--r--README.md10
-rw-r--r--examples/snac_netbsd34
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 @@
1PREFIX=/usr/pkg
2PREFIX_MAN=$(PREFIX)/man
3CFLAGS?=-g -Wall -Wextra
4
5all: snac
6
7snac: 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
15clean:
16 rm -rf *.o *.core snac makefile.depend
17
18dep:
19 $(CC) -I/usr/pkg/include -MM *.c > makefile.depend
20
21install:
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
31uninstall:
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
37activitypub.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
39data.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
41format.o: format.c xs.h xs_regex.h xs_mime.h xs_html.h snac.h
42html.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
44http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \
45 snac.h
46httpd.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
48main.o: main.c xs.h xs_io.h xs_json.h snac.h xs_html.h
49mastoapi.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
52snac.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
56upgrade.o: upgrade.c xs.h xs_io.h xs_json.h xs_glob.h snac.h
57utils.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
59webfinger.o: webfinger.c xs.h xs_json.h xs_curl.h xs_mime.h snac.h \ No newline at end of file
diff --git a/README.md b/README.md
index 04c811e..6018125 100644
--- a/README.md
+++ b/README.md
@@ -46,9 +46,17 @@ On FreeBSD, to install `curl` just type:
46pkg install curl 46pkg install curl
47``` 47```
48 48
49On NetBSD, to install `curl` just type:
50
51```sh
52pkgin install curl
53```
54
49The source code is available [here](https://comam.es/what-is-snac). 55The source code is available [here](https://comam.es/what-is-snac).
50 56
51Run `make` and then `make install` as root. 57Run `make` and then `make install` as root.
58
59If 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
53From version 2.27, `snac` includes support for the Mastodon API; if you are not interested on it, you can compile it out by running 61From 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
9name="snac"
10rcvar=${name}
11command="/usr/pkg/bin/snac"
12command_args="httpd /PATH/TO/SNACDATA"
13snac_log="/var/log/snac.log"
14pidfile="/var/run/${name}/${name}.pid"
15start_precmd="snac_precmd"
16run_as_user="SNACUSER"
17
18snac_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
33load_rc_config $name
34run_rc_command "$1" \ No newline at end of file