diff --git a/README.md b/README.md index ed98111..d93f87e 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,19 @@ The FreeBSD ntfy client package doesn't have the server or web built-in. It's a I built ntfy server on FreeBSD manually and have been testing it. I decided if I was going to keep using it that I should formalize an install.  -### **Install FreeBSD prerequisites:** +### **FreeBSD prerequisites:** +I ran out of heap space building on a 2Gb FreeBSD 14.2 VM. It builds great when it was bumped to 4Gb (and more cores). + +Install build pre-reqs: `pkg install python311 py311-pip node20 npm-node20 go gmake` ### Build: +`sudo sh ./build_ntfy_server.sh` + +### Install: + `sudo sh ./install_ntfy_server.sh` ### Configure: @@ -32,13 +39,19 @@ Copy index.html to your webserver docs directory (e.g. https://ntfy.mydomain.com Use `sysrc ntfy_enable="YES"` or add `ntfy_enable="YES"` to your /etc/rc.conf or /etc/rc.conf.d/ntfy manually to enable the service. Use `service ntfy start` to start the service. -**TODO**: +### Uninstall: + +This will completely remove the binary, configs/scripts, directories, and user. Save your configs/database before running this if you want to preserve them. + +`sudo sh ./uninstall_ntfy_server.sh` + +### TODO: +I will likely rewrite all of this and create a proper port before it's all said and done. These are the things on my list in the meantime. -- Create uninstall script (or uninstall option in main script) - Create dependency checks in install script and make more robust -- Create package (probably a tarball before a real FreeBSD pkg) - Testing client and config.  + ### License The project is dual licensed under the [Apache License 2.0](LICENSE) and the [GPLv2 License](LICENSE.GPLv2). diff --git a/build_ntfy_server.sh b/build_ntfy_server.sh new file mode 100755 index 0000000..f1da22c --- /dev/null +++ b/build_ntfy_server.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +ntfy_version=2.11.0 +file_dir=`cat dir_struct` +CGO_ENABLED=1 + +# Grab Release tarball +fetch https://github.com/binwiederhier/ntfy/archive/refs/tags/v${ntfy_version}.tar.gz + +# Extract Release source code +tar zxvf v${ntfy_version}.tar.gz + +# Change to build directory +cd ntfy-${ntfy_version} + +# Build +make cli-deps-static-sites +make web +make web-deps +make web-build +go build + +# Up from build directory +cd .. + +# Create directory structure +mkdir pkg +for i in ${dir_struct} ;do + mkdir -p pkg$i +done + +# Copy files to directories +cp -rv rc.d/* pkg/usr/local/etc/rc.d/ +cp ntfy-${ntfy_version}/ntfy pkg/usr/local/bin/ +cp ntfy-${ntfy_version}/{server/server.yml,client/client.yml} pkg/usr/local/etc/ntfy/ + +# Make a tarball +cd pkg +tar zcvf ../ntfy_server-${ntfy_version}.tar.gz . +sha256 ../ntfy_server-${ntfy_version}.tar.gz > ../ntfy_server-${ntfy_version}.sha256 +cd .. + diff --git a/dir_struct b/dir_struct new file mode 100644 index 0000000..a0a2d26 --- /dev/null +++ b/dir_struct @@ -0,0 +1,5 @@ +/usr/local/etc/ntfy +/usr/local/bin +/var/run/ntfy +/var/cache/ntfy/attachments +/var/lib/ntfy diff --git a/install_ntfy_server.sh b/install_ntfy_server.sh index 0cac951..7f917cc 100755 --- a/install_ntfy_server.sh +++ b/install_ntfy_server.sh @@ -1,24 +1,10 @@ #!/bin/sh ntfy_version=2.11.0 -CGO_ENABLED=1 - -# Grab Release tarball -fetch https://github.com/binwiederhier/ntfy/archive/refs/tags/v${ntfy_version}.tar.gz - -# Extract Release source code -tar zxvf v${ntfy_version}.tar.gz # Change to build directory cd ntfy-${ntfy_version} -# Build -make cli-deps-static-sites -make web -make web-deps -make web-build -go build - # Copy binary to install directory cp ntfy /usr/local/bin/ @@ -30,17 +16,15 @@ cp server/server.yml client/client.yml /usr/local/etc/ntfy/ cd .. # Make executable & Copy startup scripts -chmod +x rc.d/ntfy* -cp rc.d/ntfy rc.d/ntfy-client /usr/local/etc/rc.d/ +chmod +x rc.d/ntfy* +cp rc.d/ntfy* /usr/local/etc/rc.d/ # Create ntfy user pw user add -n ntfy -c 'ntfy user' -d /var/empty -s /usr/sbin/nologin # Create directories for attachments, db, and pid file -mkdir -p /var/run/ntfy /var/cache/ntfy/attachments /var/lib/ntfy -chown ntfy /var/run/ntfy /var/cache/ntfy/attachments /var/lib/ntfy +mkdir -p /var/{run/ntfy,cache/ntfy/attachments,/lib/ntfy} +chown ntfy /var/{run/ntfy,cache/ntfy/attachments,/lib/ntfy} # Setup instructions cat postinstall - - diff --git a/uninstall_ntfy_server.sh b/uninstall_ntfy_server.sh new file mode 100755 index 0000000..a332e72 --- /dev/null +++ b/uninstall_ntfy_server.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Remove configs & rc.d scripts +rm -rv /usr/local/etc/{ntfy,rc.d/ntfy*} + +# Remove binary +rm -v /usr/local/bin/ntfy + +# Remove pid, attachment, and database directories +rm -rv /var/{run/ntfy,cache/ntfy,lib/ntfy} + +# Remove ntfy user +rmuser -v ntfy