145 lines
4 KiB
Bash
Executable file
145 lines
4 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
CWD=$(pwd)
|
|
|
|
PRGNAM=$(basename $CWD)
|
|
VERSION=${VERSION:-master}
|
|
ARCH=${ARCH:-$(uname -m)}
|
|
BUILD=${BUILD:-1}
|
|
TAG=${TAG:-cyco}
|
|
|
|
TMP=${TMP:-/tmp/$TAG}
|
|
PKG=$TMP/pkg-$PRGNAM
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
PREFIX=/usr
|
|
|
|
# Check if the gitea user and group exist. If not, then bail.
|
|
if [ "$(id -g gitea 2> /dev/null)" != "817" -o "$(id -u gitea 2> /dev/null)" != "817" ]; then
|
|
echo " You must have an 'gitea' user and group to run this script."
|
|
echo " # groupadd -g 817 gitea"
|
|
echo " # useradd -d /var/lib/gitea -g gitea -s /bin/bash -u 817 gitea"
|
|
exit 1
|
|
fi
|
|
|
|
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
|
|
ea-${VERSION}-linux-${SRC_ARCH} ] && rm $CWD/gitea-${VERSION}-linux-${SRC_ARCH}
|
|
wget -c https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-linux-${SRC_ARCH}.xz -O $CWD/gitea-${VERSION}-linux-${SRC_ARCH}.xz
|
|
xz -d $CWD/gitea-${VERSION}-linux-${SRC_ARCH}.xz
|
|
|
|
[ -e $CWD/app.ini.sample ] && rm $CWD/app.ini.sample
|
|
wget -c https://raw.githubusercontent.com/go-gitea/gitea/master/custom/conf/app.ini.sample -O $CWD/app.ini.sample
|
|
|
|
mkdir -p $PKG$PREFIX/bin/
|
|
mv $CWD/gitea-${VERSION}-linux-${SRC_ARCH} $PKG$PREFIX/bin/${PRGNAM}
|
|
chmod +x $PKG$PREFIX/bin/${PRGNAM}
|
|
|
|
mkdir -p $PKG/var/lib/gitea/{custom,data,indexers,public,log}
|
|
chown -R gitea:gitea $PKG/var/lib/gitea/{data,indexers,log}
|
|
chmod 750 $PKG/var/lib/gitea/{data,indexers,log}
|
|
mkdir -p $PKG/etc/gitea/conf
|
|
chown -R root:gitea $PKG/etc/gitea
|
|
chmod 770 $PKG/etc/gitea
|
|
|
|
mv $CWD/app.ini.sample $PKG/etc/gitea/conf/
|
|
|
|
( cd $PKG
|
|
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
|
|
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
|
|
)
|
|
|
|
mkdir -p $PKG/etc/rc.d/
|
|
cat <<EOF > $PKG/etc/rc.d/rc.$PRGNAM
|
|
#!/bin/bash
|
|
#Slackware startup deamon script
|
|
|
|
# Name of Service
|
|
NAME="Gitea Daemon"
|
|
|
|
# Command to run
|
|
CMD="/usr/bin/gitea"
|
|
|
|
# Process name of daemon, for killing it.
|
|
PROCESSNAME=\$CMD
|
|
|
|
# Option to run with deamon
|
|
OPTIONS=""
|
|
|
|
func_stop() {
|
|
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.$PRGNAM
|
|
|
|
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--------------------------------------------------------|
|
|
$PRGNAM: $PRGNAM (A painless self-hosted Git service.)
|
|
$PRGNAM:
|
|
$PRGNAM: Gitea is a community managed fork of Gogs, lightweight code hosting
|
|
$PRGNAM: solution written in Go and published under the MIT license.
|
|
$PRGNAM:
|
|
$PRGNAM: edit /etc/gitea/conf/app.ini
|
|
$PRGNAM: see https://docs.gitea.io/en-us/config-cheat-sheet/
|
|
$PRGNAM:
|
|
$PRGNAM:
|
|
$PRGNAM: https://gitea.io/
|
|
$PRGNAM:
|
|
EOF
|
|
|
|
cd $PKG
|
|
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
|
|
|
|
VERSION=${VERSION}_$($PKG$PREFIX/bin/${PRGNAM} --version | cut -d\ -f3)
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|