2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2018-06-06 15:55:20 +02:00
|
|
|
|
|
|
|
CWD=$(pwd)
|
|
|
|
|
|
|
|
PRGNAM=$(basename $CWD)
|
2019-02-06 15:30:45 +01:00
|
|
|
VERSION=${VERSION:-$(curl -s https://api.github.com/repos/go-${PRGNAM}/${PRGNAM}/releases/latest | grep tag_name | grep -o "[0-9.]*")}
|
2018-06-06 15:55:20 +02:00
|
|
|
ARCH=${ARCH:-$(uname -m)}
|
2019-06-24 14:18:43 +02:00
|
|
|
BUILD=${BUILD:-2}
|
2020-06-25 11:23:11 +02:00
|
|
|
TAG=${TAG:-gwh}
|
2018-06-06 15:55:20 +02:00
|
|
|
|
|
|
|
TMP=${TMP:-/tmp/$TAG}
|
|
|
|
PKG=$TMP/pkg-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
PREFIX=/usr
|
|
|
|
|
2024-11-18 09:55:36 +01:00
|
|
|
REPOSITORY=${REPOSITORY:-/var/cache/SlackBuilds.gwh/$PRGNAM}
|
2021-09-29 13:11:33 +02:00
|
|
|
|
|
|
|
mkdir -p $REPOSITORY
|
|
|
|
|
2019-06-24 14:18:25 +02:00
|
|
|
GITEA_WORK_DIR=/var/lib/gitea
|
|
|
|
|
2018-06-06 16:20:13 +02:00
|
|
|
# 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"
|
2019-02-06 11:27:17 +01:00
|
|
|
echo " # useradd -d /var/lib/gitea -g gitea -s /bin/bash -u 817 gitea --system "
|
2018-06-06 16:20:13 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2018-06-06 15:55:20 +02:00
|
|
|
|
|
|
|
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
|
2021-09-29 13:11:33 +02:00
|
|
|
|
|
|
|
[ ! -e $REPOSITORY/gitea-${VERSION}-linux-${SRC_ARCH}.xz ] && wget -c https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-linux-${SRC_ARCH}.xz -O $REPOSITORY/gitea-${VERSION}-linux-${SRC_ARCH}.xz
|
|
|
|
xz -d $REPOSITORY/gitea-${VERSION}-linux-${SRC_ARCH}.xz
|
2018-06-06 15:55:20 +02:00
|
|
|
|
2019-02-06 11:25:24 +01:00
|
|
|
rm -fr $PKG
|
|
|
|
|
|
|
|
mkdir -p $PKG$PREFIX/bin
|
2021-09-29 13:11:33 +02:00
|
|
|
cp $REPOSITORY/gitea-${VERSION}-linux-${SRC_ARCH} $PKG$PREFIX/bin/${PRGNAM}
|
2018-06-06 15:55:20 +02:00
|
|
|
chmod +x $PKG$PREFIX/bin/${PRGNAM}
|
|
|
|
|
2019-02-06 11:25:24 +01:00
|
|
|
mkdir -p $PKG/etc/gitea/
|
2019-02-06 12:37:00 +01:00
|
|
|
cp $CWD/app.ini $PKG/etc/gitea/app.ini.new
|
2019-02-06 11:25:24 +01:00
|
|
|
chown -R gitea:gitea $PKG/etc/gitea
|
|
|
|
chmod 770 $PKG/etc/gitea
|
|
|
|
|
2019-06-24 14:18:25 +02:00
|
|
|
mkdir -p $PKG${GITEA_WORK_DIR}/{custom,data/gitea-repositories,indexers,public,log,.ssh}
|
2019-02-06 15:30:45 +01:00
|
|
|
chown -R gitea:gitea $PKG/var/lib/gitea
|
2019-06-24 14:18:25 +02:00
|
|
|
chmod 750 $PKG${GITEA_WORK_DIR}/{data,indexers,log}
|
2018-06-06 15:55:20 +02:00
|
|
|
|
2019-02-06 12:37:00 +01:00
|
|
|
mkdir -p $PKG/var/log/gitea
|
|
|
|
chown -R gitea:gitea $PKG/var/log/gitea
|
|
|
|
|
2018-06-06 15:55:20 +02:00
|
|
|
( 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"
|
|
|
|
|
2019-02-06 12:37:00 +01:00
|
|
|
# user used to run the daemon
|
|
|
|
USERNAME=gitea
|
|
|
|
|
2018-06-06 15:55:20 +02:00
|
|
|
# Process name of daemon, for killing it.
|
|
|
|
PROCESSNAME=\$CMD
|
|
|
|
|
|
|
|
# Option to run with deamon
|
2019-02-06 11:25:24 +01:00
|
|
|
OPTIONS=" --config /etc/gitea/app.ini"
|
2018-06-06 15:55:20 +02:00
|
|
|
|
2019-02-06 15:40:03 +01:00
|
|
|
PIDFILE=/var/lib/gitea/gitea.pid
|
2019-02-06 15:30:45 +01:00
|
|
|
|
2019-06-24 14:18:25 +02:00
|
|
|
GITEA_WORK_DIR=$GITEA_WORK_DIR
|
|
|
|
|
2018-06-06 15:55:20 +02:00
|
|
|
func_stop() {
|
2019-02-06 15:30:45 +01:00
|
|
|
[ -e \$PIDFILE ] && kill \$(cat \$PIDFILE)
|
2019-02-06 15:40:03 +01:00
|
|
|
# if [ "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
|
|
|
# echo -n "Stopping \$NAME ... "
|
|
|
|
# killall \$PROCESSNAME
|
|
|
|
# sleep 2
|
|
|
|
# fi
|
2018-06-06 15:55:20 +02:00
|
|
|
|
|
|
|
if [ ! "\$(ps aux | grep \$PROCESSNAME | grep -v grep)" ]; then
|
|
|
|
echo "Done!"
|
|
|
|
else
|
|
|
|
echo "Error!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
func_start() {
|
|
|
|
echo -n "Starting \$NAME ... "
|
2019-06-24 14:18:25 +02:00
|
|
|
su - \$USERNAME -c "GITEA_WORK_DIR=$GITEA_WORK_DIR \$CMD --pid \$PIDFILE \$OPTIONS" &
|
2018-06-06 15:55:20 +02:00
|
|
|
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
|
2018-06-06 16:20:13 +02:00
|
|
|
# HOW TO EDIT
|
|
|
|
THIS FILE:
|
2018-06-06 15:55:20 +02:00
|
|
|
# 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:
|
2019-02-06 14:05:26 +01:00
|
|
|
$PRGNAM: edit /etc/gitea/app.ini
|
2018-06-06 15:55:20 +02:00
|
|
|
$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
|
|
|
|
|
2023-08-16 12:23:26 +02:00
|
|
|
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|