Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions files/openafs-client-RedHat-init
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (c) 2020 AFS-Core Ericsson
# Version v1.24, 2020-06-17
# Version v1.25, 2020-07-16
#
# openafs-client Start/Stop the OpenAFS Client
#
Expand Down Expand Up @@ -67,10 +67,10 @@ lock_routine() {

setsuid() {
if [ -f $SUIDCELLS ]; then
for CELLS in $(grep '^[^#]' $SUIDCELLS); do
while read -r CELLS; do
echo "Setting $CELLS suid"
fs setcell -cell $CELLS -suid
done
done <<<"$(grep '^[^#]' $SUIDCELLS)"
fi
}

Expand Down Expand Up @@ -99,7 +99,7 @@ get_dist_release() {
OS="openSuse"
_DIST="osuse"
else
OS=$(echo "$LsbDescription" -sd | cut -f1-4 -d" " | tr -cs '[:alpha:]' '[\n*]' | grep -v '^$' | cut -c1 | tr -d '[\n]')
OS=$(echo "$LsbDescription" | cut -f1-4 -d" " | sed -e 's/\([a-zA-Z]\)[^ ]* */\1/g' -e 's/"//')
_DIST="sle"
if [[ $LsbRelease != *.* ]]; then
patchlevel=$(awk '/^PATCHLEVEL/ {print $3}' /etc/SuSE-release 2>/dev/null)
Expand Down Expand Up @@ -173,7 +173,7 @@ setsysname() {
killafs() {
SIGNAL=$1
PIDS=$(lsof -Fp $AFS | sed -e 's/p//')
if [ "x" != "x$PIDS" ]; then
if [ -n "$PIDS" ]; then
kill -$SIGNAL $PIDS >/dev/null 2>&1
sleep 3
fi
Expand All @@ -197,11 +197,22 @@ dkms_check() {

check_kernelpackages() {
KERNEL_VERSION="$1"
if [ -n "$KERNEL_VERSION" ]; then
if ! { rpm -q kernel-headers-$KERNEL_VERSION kernel-devel-$KERNEL_VERSION; } >/dev/null 2>&1; then
echo "Needed packages for running kernel $KERNEL_VERSION missing: kernel-headers-$KERNEL_VERSION kernel-devel-$KERNEL_VERSION"
if [[ "$KERNEL_VERSION" =~ \.debug$ ]]; then
KERNEL_CHECK=$(sed -e 's/\.debug$//' <<<$KERNEL_VERSION)
# KERNEL_DEVEL="debug-devel-$KERNEL_CHECK"
echo "System is running with a non supported kernel debug version: $KERNEL_VERSION"
echo "To be able to build the AFS kernel-module the system needs to be running with a normal kernel like: kernel-$KERNEL_CHECK"
echo
exit 1
else
KERNEL_CHECK=$KERNEL_VERSION
KERNEL_DEVEL="devel-$KERNEL_VERSION"
fi
if [ -n "$KERNEL_CHECK" ]; then
if ! { rpm -q kernel-headers-$KERNEL_CHECK kernel-$KERNEL_DEVEL; } >/dev/null 2>&1; then
echo "Needed packages for running kernel $KERNEL_VERSION missing: kernel-headers-$KERNEL_CHECK kernel-$KERNEL_DEVEL"
echo "Try to install..."
yum --nogpgcheck -q -y install kernel-headers-$KERNEL_VERSION kernel-devel-$KERNEL_VERSION
yum --nogpgcheck -q -y install kernel-headers-$KERNEL_CHECK kernel-$KERNEL_DEVEL
CHKKERNELPACK="false"
fi
fi
Expand Down Expand Up @@ -320,9 +331,8 @@ check_kernelmodule() {
fi
[ $RETVAL -eq 0 ] && rm -f $KMOD_BUILDLOG && echo -n "Build succeded!" && success "Build succeded!" && echo && return 0

echo "Failed to build kernel module."
failure "Failed to build kernel module."
echo "See $KMOD_BUILDLOG for more details."
echo "Failed to build kernel module, see $KMOD_BUILDLOG for more details. "
failure "Failed to build kernel module, see $KMOD_BUILDLOG for more details."
echo
return 1
else
Expand Down Expand Up @@ -502,7 +512,7 @@ stop-force() {
echo
return 1
fi
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
echo
echo "Sending all processes using $AFS the TERM signal ..."
killafs TERM
Expand Down
34 changes: 22 additions & 12 deletions files/openafs-client-RedHat-systemd-exec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (c) 2020 AFS-Core Ericsson
# Version v1.24, 2020-06-17
# Version v1.25, 2020-07-16
#
# systemd-exec.openafs-client native system exec-script
#
Expand Down Expand Up @@ -60,10 +60,10 @@ lock_routine() {

setsuid() {
if [ -f $SUIDCELLS ]; then
for CELLS in $(grep '^[^#]' $SUIDCELLS); do
while read -r CELLS; do
echo "Setting $CELLS suid"
fs setcell -cell $CELLS -suid
done
done <<<"$(grep '^[^#]' $SUIDCELLS)"
fi
}

Expand Down Expand Up @@ -92,7 +92,7 @@ get_dist_release() {
OS="openSuse"
_DIST="osuse"
else
OS=$(echo "$LsbDescription" -sd | cut -f1-4 -d" " | tr -cs '[:alpha:]' '[\n*]' | grep -v '^$' | cut -c1 | tr -d '[\n]')
OS=$(echo "$LsbDescription" | cut -f1-4 -d" " | sed -e 's/\([a-zA-Z]\)[^ ]* */\1/g' -e 's/"//')
_DIST="sle"
if [[ $LsbRelease != *.* ]]; then
patchlevel=$(awk '/^PATCHLEVEL/ {print $3}' /etc/SuSE-release 2>/dev/null)
Expand Down Expand Up @@ -166,7 +166,7 @@ setsysname() {
killafs() {
SIGNAL=$1
PIDS=$(lsof -Fp $AFS | sed -e 's/p//')
if [ "x" != "x$PIDS" ]; then
if [ -n "$PIDS" ]; then
kill -$SIGNAL $PIDS >/dev/null 2>&1
sleep 3
fi
Expand All @@ -189,11 +189,22 @@ dkms_check() {

check_kernelpackages() {
KERNEL_VERSION="$1"
if [ -n "$KERNEL_VERSION" ]; then
if ! { rpm -q kernel-headers-$KERNEL_VERSION kernel-devel-$KERNEL_VERSION; } >/dev/null 2>&1; then
echo "Needed packages for running kernel $KERNEL_VERSION missing: kernel-headers-$KERNEL_VERSION kernel-devel-$KERNEL_VERSION"
if [[ "$KERNEL_VERSION" =~ \.debug$ ]]; then
KERNEL_CHECK=$(sed -e 's/\.debug$//' <<<$KERNEL_VERSION)
# KERNEL_DEVEL="debug-devel-$KERNEL_CHECK"
echo "System is running with a non supported kernel debug version: $KERNEL_VERSION"
echo "To be able to build the AFS kernel-module the system needs to be running with a normal kernel like: kernel-$KERNEL_CHECK"
echo
exit 1
else
KERNEL_CHECK=$KERNEL_VERSION
KERNEL_DEVEL="devel-$KERNEL_VERSION"
fi
if [ -n "$KERNEL_CHECK" ]; then
if ! { rpm -q kernel-headers-$KERNEL_CHECK kernel-$KERNEL_DEVEL; } >/dev/null 2>&1; then
echo "Needed packages for running kernel $KERNEL_VERSION missing: kernel-headers-$KERNEL_CHECK kernel-$KERNEL_DEVEL"
echo "Try to install..."
yum --nogpgcheck -q -y install kernel-headers-$KERNEL_VERSION kernel-devel-$KERNEL_VERSION
yum --nogpgcheck -q -y install kernel-headers-$KERNEL_CHECK kernel-$KERNEL_DEVEL
CHKKERNELPACK="false"
fi
fi
Expand Down Expand Up @@ -312,8 +323,7 @@ check_kernelmodule() {
fi
[ $RETVAL -eq 0 ] && rm -f $KMOD_BUILDLOG && echo -n "Build succeded!" && success "Build succeded!" && echo && return 0

echo "Failed to build kernel module."
echo "See $KMOD_BUILDLOG for more details."
echo "Failed to build kernel module, see $KMOD_BUILDLOG for more details."
echo
return 1
else
Expand Down Expand Up @@ -487,7 +497,7 @@ stop-force() {
echo
return 1
fi
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
echo
echo "Sending all processes using $AFS the TERM signal ..."
killafs TERM
Expand Down
22 changes: 10 additions & 12 deletions files/openafs-client-Suse-init
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright (c) 2020 AFS-Core Ericsson
# Version v1.22, 2020-01-10
# Version v1.23, 2020-07-15
#
# System startup script for OpenAFS
#
Expand All @@ -19,7 +19,6 @@
### END INIT INFO

DAEMON="OpenAFS Client"
SUPPORTS_HUP="no"
DAEMON_BIN=/usr/sbin/afsd
AFS_KERNEL_MODULE=libafs
AFS=/afs
Expand Down Expand Up @@ -89,10 +88,10 @@ lock_routine() {

setsuid() {
if [ -f $SUIDCELLS ]; then
for CELLS in $(grep '^[^#]' $SUIDCELLS); do
while read -r CELLS; do
echo "Setting $CELLS suid"
fs setcell -cell $CELLS -suid
done
done <<<"$(grep '^[^#]' $SUIDCELLS)"
fi
}

Expand Down Expand Up @@ -121,7 +120,7 @@ get_dist_release() {
OS="openSuse"
_DIST="osuse"
else
OS=$(echo "$LsbDescription" -sd | cut -f1-4 -d" " | tr -cs '[:alpha:]' '[\n*]' | grep -v '^$' | cut -c1 | tr -d '[\n]')
OS=$(echo "$LsbDescription" | cut -f1-4 -d" " | sed -e 's/\([a-zA-Z]\)[^ ]* */\1/g' -e 's/"//')
_DIST="sle"
if [[ $LsbRelease != *.* ]]; then
patchlevel=$(awk '/^PATCHLEVEL/ {print $3}' /etc/SuSE-release 2>/dev/null)
Expand Down Expand Up @@ -195,7 +194,7 @@ setsysname() {
killafs() {
SIGNAL=$1
PIDS=$(lsof -Fp $AFS | sed -e 's/p//')
if [ "x" != "x$PIDS" ]; then
if [ -n "$PIDS" ]; then
kill -$SIGNAL $PIDS >/dev/null 2>&1
sleep 3
fi
Expand Down Expand Up @@ -340,8 +339,7 @@ case "$1" in
package_update
rm_wrong_module
if check_kernelmodule; then
ps ax | grep -q '\[afsd\]'
if [ $? -ne 0 ]; then
if ! pgrep -xf 'afsd' &>/dev/null; then
if [ "$CLEANCACHE" == "true" ]; then
if [ "${CACHEDIR}" == "/usr/vice/cache" ] || [ "${CACHEDIR}" == "/var/cache/openafs" ]; then
if [ -d ${CACHEDIR} ]; then
Expand Down Expand Up @@ -383,7 +381,7 @@ case "$1" in
exit 4
fi
echo -n "Shutting down $DAEMON "
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
umount $AFS
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
Expand Down Expand Up @@ -411,7 +409,7 @@ case "$1" in
exit 4
fi
echo -n "Shutting down $DAEMON "
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
echo
echo "Sending all processes using $AFS the TERM signal ..."
killafs TERM
Expand Down Expand Up @@ -458,13 +456,13 @@ case "$1" in

# NOTE: checkproc returns LSB compliant status values.

ps ax | grep -q '\[afsd\]' || rc_failed 3
pgrep -xf 'afsd' &>/dev/null || rc_failed 3

rc_status -v
;;
check)
echo -n "Checking $DAEMON "
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
get_cell
HEALTHCHECK=/afs/$CELL/afsadm/bin/afs_site_health_check.sh
if [ -x $HEALTHCHECK ]; then
Expand Down
22 changes: 10 additions & 12 deletions files/openafs-client-Suse-systemd-exec
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash
#
# Copyright (c) 2020 AFS-Core Ericsson
# Version v1.22, 2020-01-10
# Version v1.23, 2020-07-15
#
# systemd-exec.openafs-client native system exec-script
#

DAEMON="OpenAFS Client"
SUPPORTS_HUP="no"
DAEMON_BIN=/usr/sbin/afsd
AFS_KERNEL_MODULE=libafs
AFS=/afs
Expand Down Expand Up @@ -77,10 +76,10 @@ lock_routine() {

setsuid() {
if [ -f $SUIDCELLS ]; then
for CELLS in $(grep '^[^#]' $SUIDCELLS); do
while read -r CELLS; do
echo "Setting $CELLS suid"
fs setcell -cell $CELLS -suid
done
done <<<"$(grep '^[^#]' $SUIDCELLS)"
fi
}

Expand Down Expand Up @@ -109,7 +108,7 @@ get_dist_release() {
OS="openSuse"
_DIST="osuse"
else
OS=$(echo "$LsbDescription" -sd | cut -f1-4 -d" " | tr -cs '[:alpha:]' '[\n*]' | grep -v '^$' | cut -c1 | tr -d '[\n]')
OS=$(echo "$LsbDescription" | cut -f1-4 -d" " | sed -e 's/\([a-zA-Z]\)[^ ]* */\1/g' -e 's/"//')
_DIST="sle"
if [[ $LsbRelease != *.* ]]; then
patchlevel=$(awk '/^PATCHLEVEL/ {print $3}' /etc/SuSE-release 2>/dev/null)
Expand Down Expand Up @@ -183,7 +182,7 @@ setsysname() {
killafs() {
SIGNAL=$1
PIDS=$(lsof -Fp $AFS | sed -e 's/p//')
if [ "x" != "x$PIDS" ]; then
if [ -n "$PIDS" ]; then
kill -$SIGNAL $PIDS >/dev/null 2>&1
sleep 3
fi
Expand Down Expand Up @@ -328,8 +327,7 @@ case "$1" in
package_update
rm_wrong_module
if check_kernelmodule; then
ps ax | grep -q '\[afsd\]'
if [ $? -ne 0 ]; then
if ! pgrep -xf 'afsd' &>/dev/null; then
if [ "$CLEANCACHE" == "true" ]; then
if [ "${CACHEDIR}" == "/usr/vice/cache" ] || [ "${CACHEDIR}" == "/var/cache/openafs" ]; then
if [ -d ${CACHEDIR} ]; then
Expand Down Expand Up @@ -371,7 +369,7 @@ case "$1" in
exit 4
fi
echo -n "Shutting down $DAEMON "
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
umount $AFS
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
Expand Down Expand Up @@ -399,7 +397,7 @@ case "$1" in
exit 4
fi
echo -n "Shutting down $DAEMON "
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
echo
echo "Sending all processes using $AFS the TERM signal ..."
killafs TERM
Expand Down Expand Up @@ -446,13 +444,13 @@ case "$1" in

# NOTE: checkproc returns LSB compliant status values.

ps ax | grep -q '\[afsd\]' || rc_failed 3
pgrep -xf 'afsd' &>/dev/null || rc_failed 3

rc_status -v
;;
check)
echo -n "Checking $DAEMON "
if ps ax | grep -q '\[afsd\]'; then
if pgrep -xf 'afsd' &>/dev/null; then
get_cell
HEALTHCHECK=/afs/$CELL/afsadm/bin/afs_site_health_check.sh
if [ -x $HEALTHCHECK ]; then
Expand Down
Loading