Refactor build/install process
This commit is contained in:
21
README.md
21
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.
|
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`
|
`pkg install python311 py311-pip node20 npm-node20 go gmake`
|
||||||
|
|
||||||
### Build:
|
### Build:
|
||||||
|
|
||||||
|
`sudo sh ./build_ntfy_server.sh`
|
||||||
|
|
||||||
|
### Install:
|
||||||
|
|
||||||
`sudo sh ./install_ntfy_server.sh`
|
`sudo sh ./install_ntfy_server.sh`
|
||||||
|
|
||||||
### Configure:
|
### 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.
|
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 dependency checks in install script and make more robust
|
||||||
- Create package (probably a tarball before a real FreeBSD pkg)
|
|
||||||
- Testing client and config.
|
- Testing client and config.
|
||||||
|
|
||||||
|
|
||||||
### License
|
### License
|
||||||
The project is dual licensed under the [Apache License 2.0](LICENSE) and the [GPLv2 License](LICENSE.GPLv2).
|
The project is dual licensed under the [Apache License 2.0](LICENSE) and the [GPLv2 License](LICENSE.GPLv2).
|
||||||
|
|
||||||
|
|||||||
42
build_ntfy_server.sh
Executable file
42
build_ntfy_server.sh
Executable file
@ -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 ..
|
||||||
|
|
||||||
5
dir_struct
Normal file
5
dir_struct
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/usr/local/etc/ntfy
|
||||||
|
/usr/local/bin
|
||||||
|
/var/run/ntfy
|
||||||
|
/var/cache/ntfy/attachments
|
||||||
|
/var/lib/ntfy
|
||||||
@ -1,24 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
ntfy_version=2.11.0
|
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
|
# Change to build directory
|
||||||
cd ntfy-${ntfy_version}
|
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
|
# Copy binary to install directory
|
||||||
cp ntfy /usr/local/bin/
|
cp ntfy /usr/local/bin/
|
||||||
|
|
||||||
@ -31,16 +17,14 @@ cd ..
|
|||||||
|
|
||||||
# Make executable & Copy startup scripts
|
# Make executable & Copy startup scripts
|
||||||
chmod +x rc.d/ntfy*
|
chmod +x rc.d/ntfy*
|
||||||
cp rc.d/ntfy rc.d/ntfy-client /usr/local/etc/rc.d/
|
cp rc.d/ntfy* /usr/local/etc/rc.d/
|
||||||
|
|
||||||
# Create ntfy user
|
# Create ntfy user
|
||||||
pw user add -n ntfy -c 'ntfy user' -d /var/empty -s /usr/sbin/nologin
|
pw user add -n ntfy -c 'ntfy user' -d /var/empty -s /usr/sbin/nologin
|
||||||
|
|
||||||
# Create directories for attachments, db, and pid file
|
# Create directories for attachments, db, and pid file
|
||||||
mkdir -p /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 /var/cache/ntfy/attachments /var/lib/ntfy
|
chown ntfy /var/{run/ntfy,cache/ntfy/attachments,/lib/ntfy}
|
||||||
|
|
||||||
# Setup instructions
|
# Setup instructions
|
||||||
cat postinstall
|
cat postinstall
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
13
uninstall_ntfy_server.sh
Executable file
13
uninstall_ntfy_server.sh
Executable file
@ -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
|
||||||
Reference in New Issue
Block a user