Merge pull request #528 from micmac1/fs-init2
freeswitch-stable: improve init script
This commit is contained in:
commit
7408b6245f
3 changed files with 34 additions and 76 deletions
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||||
PRG_NAME:=freeswitch
|
PRG_NAME:=freeswitch
|
||||||
PKG_NAME:=$(PRG_NAME)-stable
|
PKG_NAME:=$(PRG_NAME)-stable
|
||||||
PKG_VERSION:=1.10.2
|
PKG_VERSION:=1.10.2
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=5
|
||||||
PKG_MAINTAINER:=Sebastian Kemper <sebastian_ml@gmx.net>
|
PKG_MAINTAINER:=Sebastian Kemper <sebastian_ml@gmx.net>
|
||||||
|
|
||||||
PKG_SOURCE:=$(PRG_NAME)-$(PKG_VERSION).-release.tar.xz
|
PKG_SOURCE:=$(PRG_NAME)-$(PKG_VERSION).-release.tar.xz
|
||||||
|
@ -366,9 +366,10 @@ $(call Package/$(PKG_NAME)/Default)
|
||||||
MENU:=1
|
MENU:=1
|
||||||
USERID:=$(PRG_NAME)=372:$(PRG_NAME)=372
|
USERID:=$(PRG_NAME)=372:$(PRG_NAME)=372
|
||||||
DEPENDS:= \
|
DEPENDS:= \
|
||||||
+@OPENSSL_WITH_DEPRECATED \
|
|
||||||
$(CXX_DEPENDS) \
|
$(CXX_DEPENDS) \
|
||||||
$(ICONV_DEPENDS) \
|
$(ICONV_DEPENDS) \
|
||||||
|
+!BUSYBOX_DEFAULT_SU:shadow-su \
|
||||||
|
+@OPENSSL_WITH_DEPRECATED \
|
||||||
+FS_STABLE_WITH_FREETYPE:libfreetype \
|
+FS_STABLE_WITH_FREETYPE:libfreetype \
|
||||||
+FS_STABLE_WITH_ODBC:unixodbc \
|
+FS_STABLE_WITH_ODBC:unixodbc \
|
||||||
+FS_STABLE_WITH_PNG:libpng \
|
+FS_STABLE_WITH_PNG:libpng \
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
config freeswitch 'general'
|
config freeswitch 'general'
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
option user 'freeswitch'
|
|
||||||
option group 'freeswitch'
|
|
||||||
option log_stderr '1'
|
option log_stderr '1'
|
||||||
option log_stdout '1'
|
option log_stdout '1'
|
||||||
option options '-nonat -np'
|
option options '-nonat -np'
|
||||||
|
|
|
@ -13,26 +13,9 @@ COMMAND=/usr/bin/$NAME
|
||||||
LOGGER="/usr/bin/logger -p user.err -s -t $NAME --"
|
LOGGER="/usr/bin/logger -p user.err -s -t $NAME --"
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
local dir
|
dir_etc=/etc/$NAME
|
||||||
local enabled
|
dir_localstate=/var/lib/$NAME
|
||||||
|
dir_run=/var/run/$NAME
|
||||||
local user
|
|
||||||
local group
|
|
||||||
|
|
||||||
local log_stderr
|
|
||||||
local log_stdout
|
|
||||||
|
|
||||||
local dir_cache
|
|
||||||
local dir_db
|
|
||||||
local dir_etc=/etc/$NAME
|
|
||||||
local dir_localstate=/var/lib/$NAME
|
|
||||||
local dir_log
|
|
||||||
local dir_recordings
|
|
||||||
local dir_run=/var/run/$NAME
|
|
||||||
local dir_storage
|
|
||||||
local dir_temp
|
|
||||||
|
|
||||||
local options
|
|
||||||
|
|
||||||
config_load $NAME
|
config_load $NAME
|
||||||
|
|
||||||
|
@ -42,9 +25,6 @@ start_service() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
config_get user general user $NAME
|
|
||||||
config_get group general group $NAME
|
|
||||||
|
|
||||||
config_get_bool log_stderr general log_stderr 1
|
config_get_bool log_stderr general log_stderr 1
|
||||||
config_get_bool log_stdout general log_stdout 1
|
config_get_bool log_stdout general log_stdout 1
|
||||||
|
|
||||||
|
@ -55,54 +35,34 @@ start_service() {
|
||||||
config_get dir_storage directories storage /tmp/$NAME/storage
|
config_get dir_storage directories storage /tmp/$NAME/storage
|
||||||
config_get dir_temp directories temp /tmp/$NAME/temp
|
config_get dir_temp directories temp /tmp/$NAME/temp
|
||||||
|
|
||||||
user_exists "$user" || {
|
|
||||||
$LOGGER user \""$user"\" does not exist
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
group_exists "$group" || {
|
|
||||||
$LOGGER group \""$group"\" does not exist
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# do not touch directories that already exist
|
|
||||||
# posix shell does not support arrays, hence using awk
|
|
||||||
awk \
|
|
||||||
-v user="$user" \
|
|
||||||
-v group="$group" \
|
|
||||||
-v a="$dir_cache" \
|
|
||||||
-v b="$dir_db" \
|
|
||||||
-v c="$dir_localstate" \
|
|
||||||
-v d="$dir_log" \
|
|
||||||
-v e="$dir_recordings" \
|
|
||||||
-v f="$dir_run" \
|
|
||||||
-v g="$dir_storage" \
|
|
||||||
-v h="$dir_temp" \
|
|
||||||
'
|
|
||||||
BEGIN {
|
|
||||||
dir[0]=a
|
|
||||||
dir[1]=b
|
|
||||||
dir[2]=c
|
|
||||||
dir[3]=d
|
|
||||||
dir[4]=e
|
|
||||||
dir[5]=f
|
|
||||||
dir[6]=g
|
|
||||||
dir[7]=h
|
|
||||||
for (x in dir) {
|
|
||||||
if (system("test ! -e \"" dir[x] "\"" )) {
|
|
||||||
delete dir[x]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (x in dir) {
|
|
||||||
system("mkdir -p \"" dir[x] "\"" )
|
|
||||||
system("chmod 750 \"" dir[x] "\"" )
|
|
||||||
system("chown \"" user "\":\"" group "\" \"" dir[x] "\"" )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'
|
|
||||||
|
|
||||||
config_get options general options
|
config_get options general options
|
||||||
|
|
||||||
|
for i in "$dir_localstate" "$dir_run"; do
|
||||||
|
if ! [ -e "$i" ]; then
|
||||||
|
mkdir -m 0750 -p "$i"
|
||||||
|
[ -d "$i" ] && chown $NAME:$NAME "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
command -v su >/dev/null
|
||||||
|
ret=$?
|
||||||
|
if [ 0 != "$ret" ]; then
|
||||||
|
$LOGGER utility \"su\" not available
|
||||||
|
$LOGGER will not attempt to create directories
|
||||||
|
else
|
||||||
|
for i in "$dir_cache" \
|
||||||
|
"$dir_db" \
|
||||||
|
"$dir_log" \
|
||||||
|
"$dir_recordings" \
|
||||||
|
"$dir_storage" \
|
||||||
|
"$dir_temp";
|
||||||
|
do
|
||||||
|
if ! [ -e "$i" ]; then
|
||||||
|
su -s /bin/sh -c "mkdir -m 0750 -p \"$i\"" $NAME
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
# starting with full path seems cleaner judging by 'ps' output
|
# starting with full path seems cleaner judging by 'ps' output
|
||||||
procd_set_param command $COMMAND
|
procd_set_param command $COMMAND
|
||||||
|
@ -111,13 +71,13 @@ start_service() {
|
||||||
-cache "$dir_cache" \
|
-cache "$dir_cache" \
|
||||||
-conf "$dir_etc" \
|
-conf "$dir_etc" \
|
||||||
-db "$dir_db" \
|
-db "$dir_db" \
|
||||||
-g "$group" \
|
-g "$NAME" \
|
||||||
-log "$dir_log" \
|
-log "$dir_log" \
|
||||||
-recordings "$dir_recordings" \
|
-recordings "$dir_recordings" \
|
||||||
-run "$dir_run" \
|
-run "$dir_run" \
|
||||||
-storage "$dir_storage" \
|
-storage "$dir_storage" \
|
||||||
-temp "$dir_temp" \
|
-temp "$dir_temp" \
|
||||||
-u "$user" \
|
-u "$NAME" \
|
||||||
$options \
|
$options \
|
||||||
-c
|
-c
|
||||||
# forward stderr to logd
|
# forward stderr to logd
|
||||||
|
@ -126,4 +86,3 @@ start_service() {
|
||||||
procd_set_param stdout $log_stdout
|
procd_set_param stdout $log_stdout
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue