#!/bin/bash CWD=$(pwd) PRGNAM=$(basename "$CWD") VERSION=${VERSION:-latest} ARCH=${ARCH:-$(uname -m)} BUILD=${BUILD:-2} TAG=${TAG:-gwh} TMP=${TMP:-/tmp/$TAG} PKG=$TMP/pkg-$PRGNAM OUTPUT=${OUTPUT:-/tmp} PREFIX=/usr REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/_repositories/$PRGNAM} APP_WORK_DIR=/var/lib/gitea # Check if the gitea user and group exist. If not, then bail. if [ "$(id -g gitea 2> /dev/null)" != "817" ] || [ "$(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 --system " exit 1 fi # nettoyage préalable rm -r "$PKG" "{$TMP:?}/$PRGNAM" mkdir -p "$PKG" # mise en place [ ! -e "$REPOSITORY" ] && git clone https://codeberg.org/forgejo/forgejo.git "$REPOSITORY" cd "$REPOSITORY" || exit 1 git pull --all mkdir -p "$TMP" cp -r "$REPOSITORY" "$TMP/" cd "$TMP/$PRGNAM" || exit 1 case $VERSION in trunk) VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)" ;; latest) VERSION=$(git describe --tags --abbrev=0) git checkout "$VERSION" ;; *) git checkout "$VERSION" ;; esac make mkdir -p "$PKG$PREFIX"/bin cp gitea "$PKG$PREFIX"/bin/gitea # ${PRGNAM} chmod +x "$PKG$PREFIX"/bin/gitea # ${PRGNAM} mkdir -p "$PKG$PREFIX/doc/$PRGNAM" cp -r DCO LICENSE MAINTAINERS ./*.md docs/ "$PKG$PREFIX/doc/$PRGNAM" mkdir -p "$PKG"/etc/gitea/ cp "$CWD"/app.ini "$PKG"/etc/gitea/app.ini.new chown -R gitea:gitea "$PKG"/etc/gitea chmod 770 "$PKG"/etc/gitea mkdir -p "$PKG${APP_WORK_DIR}"/{custom,data/gitea-repositories,indexers,public,log,.ssh} chown -R gitea:gitea "$PKG"/var/lib/gitea chmod 750 "$PKG${APP_WORK_DIR}"/{data,indexers,log} mkdir -p "$PKG"/var/log/gitea chown -R gitea:gitea "$PKG"/var/log/gitea cd "$PKG" || exit 1 find . -print0 | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true find . -print0 | 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 < "$PKG"/etc/rc.d/rc.gitea #!/bin/bash #Slackware startup deamon script # Name of Service NAME="Gitea Daemon" # Command to run CMD="/usr/bin/gitea" # user used to run the daemon USERNAME=gitea # Process name of daemon, for killing it. PROCESSNAME=\$CMD # Option to run with deamon OPTIONS=" --config /etc/gitea/app.ini" PIDFILE=/var/lib/gitea/gitea.pid APP_WORK_DIR=$APP_WORK_DIR 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 "GITEA_WORK_DIR=$APP_WORK_DIR \$CMD --pid \$PIDFILE \$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.gitea mkdir -p "$PKG"/install cat < "$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 self-hosted lightweight software forge.) $PRGNAM: $PRGNAM: Brought to you by an inclusive community under the umbrella of Codeberg $PRGNAM: e.V., a democratic non-profit organization, Forgejo can be trusted to be $PRGNAM: exclusively Free Software. It includes and cooperates with hundreds of $PRGNAM: projects (Gitea, Git, ...) and is focused on scaling, federation and $PRGNAM: privacy. $PRGNAM: $PRGNAM: edit /etc/gitea/app.ini $PRGNAM: https://forgejo.org/ $PRGNAM: EOF cd "$PKG" || exit 1 rm -f "$PKG"/{,usr/}lib"$(uname -m | grep -o 64)"/*.la /sbin/makepkg --linkadd y --chown n --prepend "$OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz"