Support of Debian 9 (stretch) samba installation.
This commit is contained in:
parent
63b2fa45a8
commit
4bfd9b87f6
@ -3,6 +3,9 @@
|
|||||||
working_dir="$(dirname $(realpath $0))"
|
working_dir="$(dirname $(realpath $0))"
|
||||||
|
|
||||||
|
|
||||||
|
service_name="samba"
|
||||||
|
check_string_ps="(sbin/smbd| sbin/samba )"
|
||||||
|
|
||||||
# -------------
|
# -------------
|
||||||
# - Some Variables
|
# - Some Variables
|
||||||
# -------------
|
# -------------
|
||||||
@ -148,22 +151,20 @@ if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then
|
|||||||
systemd_supported=true
|
systemd_supported=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_string_ps="(sbin/smbd | sbin/samba )"
|
|
||||||
|
|
||||||
# - Check How to start/stop service
|
# - Check How to start/stop service
|
||||||
# -
|
# -
|
||||||
SYSTEMD_UNIT_FILE=""
|
SYSTEMD_UNIT_FILE=""
|
||||||
SYSY_INIT_SCRIPT=""
|
SYSY_INIT_SCRIPT=""
|
||||||
if $systemd_supported ; then
|
if $systemd_supported ; then
|
||||||
SYSTEMD_UNIT_FILE="$(systemctl list-unit-files | grep -E "samba[^@]*\.service" | grep "enabled" | cut -d' ' -f1)"
|
SYSTEMD_UNIT_FILE="$(systemctl list-unit-files | grep -E "${service_name}[^@]*\.service" | grep "enabled" | cut -d' ' -f1)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$SYSTEMD_UNIT_FILE" ]]; then
|
if [[ -z "$SYSTEMD_UNIT_FILE" ]]; then
|
||||||
SYSY_INIT_SCRIPT="$(service --status-all | awk '{print$4}' | grep samba | head -1)"
|
SYSY_INIT_SCRIPT="$(service --status-all | awk '{print$4}' | grep ${service_name} | head -1)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$SYSTEMD_UNIT_FILE" ]] && [[ -z "$SYSY_INIT_SCRIPT" ]] ; then
|
if [[ -z "$SYSTEMD_UNIT_FILE" ]] && [[ -z "$SYSY_INIT_SCRIPT" ]] ; then
|
||||||
fatal 'Neither an init-script nor a service file for samba service found!'
|
fatal "Neither an init-script nor a service file for ${service_name} service found!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -172,17 +173,17 @@ fi
|
|||||||
# -------------
|
# -------------
|
||||||
|
|
||||||
if $terminal ; then
|
if $terminal ; then
|
||||||
echo -e "\n Check if Samba Service is running.."
|
echo -e "\n Check if Service '${service_name}' is running.."
|
||||||
echo -e " ==================================="
|
echo -e " ====================================="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PIDS="$(ps ax | grep -E "$check_string_ps" | grep -v grep | awk '{print$1}')"
|
PIDS="$(ps ax | grep -E "$check_string_ps" | grep -v grep | awk '{print$1}')"
|
||||||
|
|
||||||
if [[ -z "$PIDS" ]];then
|
if [[ -z "$PIDS" ]];then
|
||||||
|
|
||||||
error "Samba Service seems to be down. Try to (re)start .."
|
error "$service_name service seems to be down. Try to (re)start .."
|
||||||
|
|
||||||
echononl " Stop Samba Service first .."
|
echononl " Stop Service '${service_name}' first .."
|
||||||
if [[ -n "$SYSTEMD_UNIT_FILE" ]] ; then
|
if [[ -n "$SYSTEMD_UNIT_FILE" ]] ; then
|
||||||
systemctl stop $SYSTEMD_UNIT_FILE > /dev/null 2>&1
|
systemctl stop $SYSTEMD_UNIT_FILE > /dev/null 2>&1
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
@ -201,7 +202,7 @@ if [[ -z "$PIDS" ]];then
|
|||||||
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
echononl " Start Samba Service .."
|
echononl " Start Service '${service_name}' .."
|
||||||
if [[ -n "$SYSTEMD_UNIT_FILE" ]] ; then
|
if [[ -n "$SYSTEMD_UNIT_FILE" ]] ; then
|
||||||
systemctl start $SYSTEMD_UNIT_FILE > /dev/null 2>&1
|
systemctl start $SYSTEMD_UNIT_FILE > /dev/null 2>&1
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
@ -228,11 +229,11 @@ if [[ -z "$PIDS" ]];then
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "${PIDS}" ]] ; then
|
if [[ -z "${PIDS}" ]] ; then
|
||||||
error "Restarting Samba Service failed"
|
error "Restarting Service '${service_name}' failed"
|
||||||
else
|
else
|
||||||
|
|
||||||
NEW_PIDS=""
|
NEW_PIDS=""
|
||||||
count=0
|
count=1
|
||||||
for _pid in $PIDS ; do
|
for _pid in $PIDS ; do
|
||||||
if [[ $count -eq 1 ]] ; then
|
if [[ $count -eq 1 ]] ; then
|
||||||
NEW_PIDS="$_pid"
|
NEW_PIDS="$_pid"
|
||||||
@ -242,17 +243,20 @@ if [[ -z "$PIDS" ]];then
|
|||||||
((count++))
|
((count++))
|
||||||
done
|
done
|
||||||
|
|
||||||
info "the new PIDs are $NEW_PIDS"
|
info "Service '${service_name}' was restarted and is now up and running.
|
||||||
|
The new PID is $NEW_PIDS"
|
||||||
|
|
||||||
echo ""
|
if ! $terminal ; then
|
||||||
echo "[ Success ]: Samba Service was restarted and is now up and running."
|
echo ""
|
||||||
echo " The new PIDs are $NEW_PIDS"
|
echo "[ Success ]: Service '${service_name}' was restarted and is now up and running."
|
||||||
echo ""
|
echo " The new PIDs are $NEW_PIDS"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
info "Samba Service is up and running."
|
info "Service '${service_name}' is up and running."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clean_up 0
|
clean_up 0
|
||||||
|
Loading…
Reference in New Issue
Block a user