Skip to content

Commit

Permalink
Added init script and dedicated system account
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkugel committed Nov 22, 2018
1 parent b5c5e00 commit 2205c28
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
10 changes: 10 additions & 0 deletions transmission/doinst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Create a user
if [ -z "$(getent passwd transmission)" ]; then
/usr/sbin/useradd -r -m -U -c "Transmission" transmission
fi
if ! [ -f /home/transmission/.config/transmission-cli/settings.json ]; then
if ! [ -d /home/transmission/.config/transmission-cli ]; then
mkdir -p /home/transmission/.config/transmission-cli
fi
transmission-daemon -d 2> /home/transmission/.config/transmission-cli/settings.json
fi
49 changes: 49 additions & 0 deletions transmission/rc.transmission
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
# Start/stop/restart transmission.
TRANSMISSION_USER="transmission"
CMDLINE="transmission-daemon"

# Start transmission:
transmission_start() {
echo "Starting TRANSMISSION daemon..."
sudo -s -u ${TRANSMISSION_USER} ${CMDLINE}
echo
}

# Stop transmission:
transmission_stop() {
echo -n "Stopping TRANSMISSION daemon..."
killall -SIGINT -q ${CMDLINE}
echo
}

# Reload transmission:
transmission_reload() {
echo -n "Reloading TRANSMISSION daemon..."
killall -SIGHUP -q ${CMDLINE}
echo
}

# Restart transmission:
transmission_restart() {
transmission_stop
sleep 1
transmission_start
}

case "$1" in
'start')
transmission_start
;;
'stop')
transmission_stop
;;
'restart')
transmission_restart
;;
'reload')
transmission_reload
;;
*)
echo "usage $0 start|stop|restart|reload"
esac
16 changes: 13 additions & 3 deletions transmission/transmission.SlackBuild
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@ TAG='1_x'
APP_URL="https://github.com/transmission/transmission/archive/${VERSION}.tar.gz -O ${PRGNAM}-${VERSION}.tar.gz"
BUILD_DIR="/tmp/SlackBuild-${PRGNAM}-$(date +%s)"

if [ "$(getconf LONG_BIT)" == "64" ]; then
LIBDIRSUFFIX="64"
export CFLAGS="-fPIC"
export CPPFLAGS="-fPIC"
else
LIBDIRSUFFIX=""
fi

# Download
mkdir -v -p ${BUILD_DIR}/install ${BUILD_DIR}/src
mkdir -v -p ${BUILD_DIR}/install ${BUILD_DIR}/src ${BUILD_DIR}/etc/rc.d
if ! [ -f ${PRGNAM}-${VERSION}.tar.gz ]; then
wget ${APP_URL}
fi
tar -v -x -z -C ${BUILD_DIR}/src -f ./${PRGNAM}-${VERSION}.tar.gz
cp -v -f ./slack-desc ${BUILD_DIR}/install/slack-desc
cp -v -f ./slack-desc ${BUILD_DIR}/install
cp -v -f ./doinst.sh ${BUILD_DIR}/install
cp -v -f ./rc.transmission ${BUILD_DIR}/etc/rc.d

# Build
cd ${BUILD_DIR}/src/${PRGNAM}-${VERSION}
./autogen.sh && ./configure --with-crypto=openssl --prefix=/usr --libdir=/lib64
./autogen.sh && ./configure --with-crypto=openssl --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX}
DESTDIR=${BUILD_DIR} make install

cd ${BUILD_DIR}
Expand Down

0 comments on commit 2205c28

Please sign in to comment.