[n/writefreely] Added

This commit is contained in:
Gwenhael Le Moine 2023-08-14 14:07:36 +02:00
parent 218cdf8577
commit 51543dd05b
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

128
n/writefreely/SlackBuild Executable file
View file

@ -0,0 +1,128 @@
#!/bin/bash
CWD=$(pwd)
PKGNAM=$(basename "$CWD")
VERSION=${VERSION:-$(curl -s https://api.github.com/repos/writefreely/writefreely/releases/latest | grep tag_name | grep -o "[0-9.]*")}
ARCH=${ARCH:-$(uname -m)}
BUILD=${BUILD:-3}
TAG=${TAG:-gwh}
TMP=${TMP:-/tmp/$TAG}
PKG=$TMP/pkg-$PKGNAM
OUTPUT=${OUTPUT:-/tmp}
REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/_repositories/$PKGNAM}
mkdir -p "$REPOSITORY"
# echo $ARCH | grep -q arm && SRC_ARCH=arm-7
# echo $ARCH | grep -q 86 && SRC_ARCH=386
echo "$ARCH" | grep -q 64 && SRC_ARCH=amd64
[ ! -e "$REPOSITORY/writefreely_${VERSION}_linux_${SRC_ARCH}.tar.gz" ] && wget -c "https://github.com/writefreely/writefreely/releases/download/v${VERSION}/writefreely_${VERSION}_linux_${SRC_ARCH}.tar.gz" -O "$REPOSITORY/writefreely_${VERSION}_linux_${SRC_ARCH}.tar.gz"
rm -fr "$PKG"
mkdir -p "$PKG/opt"
cd "$PKG/opt" || exit 1
tar xvf "$REPOSITORY/writefreely_${VERSION}_linux_${SRC_ARCH}.tar.gz"
mkdir -p "$PKG/etc/rc.d/"
cat <<EOF > "$PKG/etc/rc.d/rc.$PKGNAM"
#!/bin/bash
#Slackware startup deamon script
# Name of Service
NAME="Writefreely Daemon"
# Command to run
CMD="/opt/writefreely/writefreely"
# user used to run the daemon
USERNAME=apache
# Process name of daemon, for killing it.
PROCESSNAME=writefreely
# Option to run with deamon
OPTIONS=""
PIDFILE=/var/run/writefreely.pid
func_stop() {
[ -e \$PIDFILE ] && kill \$(cat \$PIDFILE)
# if [ "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
# echo -n "Stopping \$NAME ... "
# killall \$PROCESSNAME
# sleep 2
# fi
if [ ! "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
echo "Done!"
else
echo "Error!"
fi
}
func_start() {
echo -n "Starting \$NAME ... "
su - \$USERNAME -c "\$CMD \$OPTIONS" &
sleep 2
if [ "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
echo "Done!"
else
echo "Error!"
fi
}
case \$1 in
"start")
func_start
;;
"stop")
func_stop
;;
"restart")
func_stop
sleep 2
func_start
;;
*)
echo "Usage; start|stop|restart"
;;
esac
EOF
chmod +x "$PKG/etc/rc.d/rc.$PKGNAM"
mkdir -p "$PKG/install"
cat <<EOF > "$PKG/install/slack-desc"
# HOW TO EDIT
THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler--------------------------------------------------------|
$PKGNAM: $PKGNAM (A clean, Markdown-based publishing platform)
$PKGNAM:
$PKGNAM: WriteFreely is a clean, minimalist publishing platform made for writers.
$PKGNAM: Start a blog, share knowledge within your organization, or build a
$PKGNAM: community around the shared act of writing.
$PKGNAM:
$PKGNAM:
$PKGNAM:
$PKGNAM:
$PKGNAM: https://writefreely.org/
$PKGNAM:
EOF
cd "$PKG" || exit 1
/sbin/makepkg -l y -c n "$OUTPUT/$PKGNAM-$VERSION-$ARCH-$BUILD$TAG.txz"