make install script work on freebsd

This commit is contained in:
davidnewhall2 2020-02-01 01:44:36 -08:00
parent 88d46a31e3
commit a3f985983d
2 changed files with 48 additions and 25 deletions

View File

@ -250,13 +250,14 @@ package_build_linux_armhf: package_build_linux armhf
# Build an environment that can be packaged for freebsd.
package_build_freebsd: readme man freebsd
mkdir -p $@/usr/local/bin $@/usr/local/etc/{rc.d,$(BINARY)} $@/usr/local/share/man/man1 $@/usr/local/share/doc/$(BINARY)
mkdir -p $@/usr/local/bin $@/usr/local/etc/$(BINARY) $@/usr/local/share/man/man1 $@/usr/local/share/doc/$(BINARY)
cp $(BINARY).amd64.freebsd $@/usr/local/bin/$(BINARY)
cp *.1.gz $@/usr/local/share/man/man1
cp examples/$(CONFIG_FILE).example $@/usr/local/etc/$(BINARY)/
cp examples/$(CONFIG_FILE).example $@/usr/local/etc/$(BINARY)/$(CONFIG_FILE)
cp LICENSE *.html examples/*?.?* $@/usr/local/share/doc/$(BINARY)/
cp init/bsd/unifi-poller.rc $@/usr/local/etc/rc.d/unifi-poller
[ "$(FORMULA)" != "service" ] || mkdir -p $@/usr/local/etc/rc.d
[ "$(FORMULA)" != "service" ] || cp init/bsd/unifi-poller.rc $@/usr/local/etc/rc.d/unifi-poller
package_build_freebsd_386: package_build_freebsd freebsd386
mkdir -p $@

View File

@ -2,35 +2,51 @@
# This is a quick and drity script to install the latest Linux package.
#
# Use it like this: (sudo is optional)
# ===
# curl https://raw.githubusercontent.com/unifi-poller/unifi-poller/master/scripts/install.sh | sudo sh
# ===
# If you're on redhat, this installs the latest rpm. If you're on Debian, it installs the latest deb package.
# Use it like this, pick curl or wget: (sudo is optional)
# ----
# curl -s https://raw.githubusercontent.com/unifi-poller/unifi-poller/master/scripts/install.sh | sudo sh
# wget -qO- https://raw.githubusercontent.com/unifi-poller/unifi-poller/master/scripts/install.sh | sudo sh
# ----
#
# - If you're on RedHat/CentOS/Fedora, installs the latest rpm package.
# - If you're on Debian/Ubuntu/Gentoo, installs the latest deb package.
# - If you're on FreeBSD, installs the latest txz package.
#
# This is part of application-builder.
# https://github.com/golift/application-builder
REPO=unifi-poller/unifi-poller
BREW=golift/mugs/unifi-poller
LATEST=https://api.github.com/repos/${REPO}/releases/latest
ARCH=$(uname -m)
OS=$(uname -s)
P=" ==>"
echo "<-------------------------------------------------->"
if [ "$OS" = "Darwin" ]; then
echo "${P} On a mac? Use Homebrew:"
echo " brew install ${BREW}"
exit
fi
# $ARCH is passed into egrep to find the right file.
if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then
ARCH="x86_64|amd64"
elif [[ $ARCH == *386* ]] || [[ $ARCH == *686* ]]; then
elif [[ $ARCH = *386* ]] || [[ $ARCH = *686* ]]; then
ARCH="i386"
elif [[ $ARCH == *arm64* ]] || [[ $ARCH == *armv8* ]] || [[ $ARCH == *aarch64* ]]; then
elif [[ $ARCH = *arm64* ]] || [[ $ARCH = *armv8* ]] || [[ $ARCH = *aarch64* ]]; then
ARCH="arm64"
elif [[ $ARCH == *armv6* ]] || [[ $ARCH == *armv7* ]]; then
elif [[ $ARCH = *armv6* ]] || [[ $ARCH = *armv7* ]]; then
ARCH="armhf"
else
echo "Unknown Architecture. Submit a pull request to fix this, please."
echo ==> $ARCH
echo "${P} [ERROR] Unknown Architecture: ${ARCH}"
echo "${P} $(uname -a)"
echo "${P} Please report this, along with the above OS details:"
echo " https://github.com/${REPO}/issues/new"
exit 1
fi
if [ "$1" == "deb" ] || [ "$1" == "rpm" ] || [ "$1" == "txz" ]; then
if [ "$1" = "deb" ] || [ "$1" = "rpm" ] || [ "$1" = "txz" ]; then
FILE=$1
else
# If you have both, rpm wins.
@ -51,23 +67,26 @@ else
fi
if [ "$FILE" = "" ]; then
echo "No pkg (freebsd), dpkg (debian) or rpm (redhat) package managers found; not sure what package to download!"
echo "${P} [ERROR] No pkg (freebsd), dpkg (debian) or rpm (redhat) package managers found; not sure what package to download!"
echo "${P} $(uname -a)"
echo "${P} If you feel this is a mistake, please report this along with the above OS details:"
echo " https://github.com/${REPO}/issues/new"
exit 1
fi
# curl or wget?
curl --version > /dev/null 2>&1
if [ "$?" = "0" ]; then
CMD="curl -L"
CMD="curl -sL"
else
wget --version > /dev/null 2>&1
if [ "$?" = "0" ]; then
CMD="wget -O-"
CMD="wget -qO-"
fi
fi
if [ "$CMD" = "" ]; then
echo "Need curl or wget - could not find either!"
echo "${P} [ERROR] Could not locate curl nor wget - please install one to download packages!"
exit 1
fi
@ -75,7 +94,10 @@ fi
URL=$($CMD ${LATEST} | egrep "browser_download_url.*(${ARCH})\.${FILE}\"" | cut -d\" -f 4)
if [ "$?" != "0" ] || [ "$URL" = "" ]; then
echo "Error locating latest release for '${FILE} (${ARCH})' at ${LATEST}"
echo "${P} [ERROR] Missing latest release for '${FILE}' file ($OS/${ARCH}) at ${LATEST}"
echo "${P} $(uname -a)"
echo "${P} Please report error this, along with the above OS details:"
echo " https://github.com/${REPO}/issues/new"
exit 1
fi
@ -87,17 +109,17 @@ elif [ "$FILE" = "txz" ]; then
fi
FILE=$(basename ${URL})
echo "Downloading: ${URL} to /tmp/${FILE}"
echo "${P} Downloading: ${URL}"
echo "${P} To Location: /tmp/${FILE}"
$CMD ${URL} > /tmp/${FILE}
# Install it.
if [ "$(id -u)" = "0" ]; then
echo "==================================="
echo "Downloaded. Installing the package!"
echo "Running: ${INSTALLER} /tmp/${FILE}"
echo "${P} Downloaded. Installing the package!"
echo "${P} Executing: ${INSTALLER} /tmp/${FILE}"
$INSTALLER /tmp/${FILE}
echo "<-------------------------------------------------->"
else
echo "================================"
echo "Downloaded. Install the package:"
echo "sudo $INSTALLER /tmp/${FILE}"
echo "${P} Downloaded. Install the package like this:"
echo " sudo $INSTALLER /tmp/${FILE}"
fi