From 90951d4a0ecb3bd9a1ed4d42c45b121695246dc0 Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 11 Sep 2022 01:03:24 +0300 Subject: [PATCH] Initial commit --- LICENSE | 20 ++++++++++++++++ README | 5 ++++ slack-desc | 19 +++++++++++++++ slackware-service.Slackbuild | 46 ++++++++++++++++++++++++++++++++++++ src/service | 46 ++++++++++++++++++++++++++++++++++++ 5 files changed, 136 insertions(+) create mode 100644 LICENSE create mode 100644 README create mode 100644 slack-desc create mode 100755 slackware-service.Slackbuild create mode 100644 src/service diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..13255ce --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2022 Sergei Fedosoff + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README b/README new file mode 100644 index 0000000..6a0f526 --- /dev/null +++ b/README @@ -0,0 +1,5 @@ +Slackware-service is a wrapper script that tries to mimic redhat "service" command. + +When you call "service something start" (for example) it simply runs "/etc/rc.d/rc.something start", thats it. +Since I spent many hours with redhat/rhel/rhel-based systems I stick with command called "service", and find it much +easier to use this kind of script instead forcing my habbit to change. diff --git a/slack-desc b/slack-desc new file mode 100644 index 0000000..7d733ed --- /dev/null +++ b/slack-desc @@ -0,0 +1,19 @@ +# 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------------------------------------------------------| +slackware-service: slackware-service (redhat-like service command wrapper) +slackware-service: +slackware-service: slackware-service privides "service" command like in old fashion +slackware-service: redhat-like distibutions. It allows to run slackware services from +slackware-service: /etc/rc.d dir like redhat ones - service service name action +slackware-service: +slackware-service: +slackware-service: +slackware-service: +slackware-service: +slackware-service: diff --git a/slackware-service.Slackbuild b/slackware-service.Slackbuild new file mode 100755 index 0000000..40e19ab --- /dev/null +++ b/slackware-service.Slackbuild @@ -0,0 +1,46 @@ +#!/bin/sh +set -eu + +# Copyright (c) 2022 Sergei Fedosoff +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +PRGNAM=slackware-service +VERSION=${VERSION:-1.0} +BUILD=${BUILD:-1} +TAG=${TAG:-_EXs} +PKGTYPE=${PKGTYPE:-tgz} + +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +mkdir -p "$PKG" + +if [ ! -d "$OUTPUT" ]; then + mkdir -p "$OUTPUT" +fi + +install -Dpm 0744 src/service "${PKG}/usr/sbin/service" +install -Dpm 0644 LICENSE "${PKG}/usr/doc/${PRGNAM}-${VERSION}/LICENSE" +install -Dpm 0644 slack-desc "${PKG}/install/slack-desc" + +cd "${PKG}" +/sbin/makepkg -l y -c n "${OUTPUT}/${PRGNAM}-${VERSION}-noarch-${BUILD}${TAG}.${PKGTYPE}" diff --git a/src/service b/src/service new file mode 100644 index 0000000..b10eb51 --- /dev/null +++ b/src/service @@ -0,0 +1,46 @@ +#!/bin/bash + +function help() { + echo "Usage: $0 service_name command" +} + + +if [[ $1 == '' ]]; then + echo "Service_name is required!" + help + exit 1 +fi + +if [[ $1 == '--help' ]]; then + help + exit 0 +fi + +if [[ $1 == '-h' ]]; then + help + exit 0 +fi + +if [[ $2 == '' ]]; then + echo "Command is required!" + help + exit 1 +fi + +if [[ -e /etc/rc.d/rc.$1 ]]; then + : +else + echo "/etc/rc.d/rc.$1 does not exist" + exit 1 +fi + +if [[ -x /etc/rc.d/rc.$1 ]]; then + : +else + echo "Bit +x is not set on /etc/rc.d/rc.$1" + exit 1 +fi + +CMD=$1 +shift 1 +exec "/etc/rc.d/rc.$CMD" "$@"