asterisk-16.x: update init and configuration
This commit changes handling of configuration and init a bit: 1. Asterisk configuration files are installed with $(INSTALL_DATA). This way there is no need to chown /etc/asterisk to user asterisk. The package provides the standard asterisk configuration (no secrets) so it's OK to install it readable for all. If users put something sensitive in there they can update permissions how they like. 2. The init script no longer creates directories that the users can configure in /etc/config/asterisk, which could be all kinds of strange directories. Instead only the default directories are created, and only the ones that reside on volatile memory. The other directories are now created by the package itself. 3. This commit removes the ability to choose a user/group via /etc/config/asterisk. This makes the init script simpler. If anybody wants to play around with the user/group, then it's up to them to fix the permissions. 4. "local" is removed because it's not POSIX. 5. From issue #520 we know that adding the user to the dialout group does not help with the device permissions for chan_lantiq. This removes it again. Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
parent
54d0fb32eb
commit
e44fb87cc7
3 changed files with 36 additions and 111 deletions
|
@ -334,7 +334,7 @@ endef
|
|||
|
||||
define Package/$(PKG_NAME)/install/conffile
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/asterisk/$(2) $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/$(2) $(1)/etc/asterisk/
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install/lib
|
||||
|
@ -354,7 +354,7 @@ endef
|
|||
|
||||
define Package/$(PKG_NAME)/install/util-conffile
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/asterisk/$(2) $(1)/etc
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/$(2) $(1)/etc
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
|
@ -498,7 +498,9 @@ $(foreach m,$(AST_CFG_FILES),$(call Package/$(PKG_NAME)/install/conffile,$(1),$(
|
|||
$(foreach m,$(AST_EMB_MODULES),$(call Package/$(PKG_NAME)/install/module,$(1),$(m));)
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/usr/share/asterisk/agi-bin
|
||||
$(INSTALL_DIR) $(1)/usr/share/asterisk/firmware/iax
|
||||
$(INSTALL_DIR) $(1)/usr/share/asterisk/keys
|
||||
$(INSTALL_DIR) $(1)/usr/share/asterisk/sounds
|
||||
$(INSTALL_BIN) ./files/asterisk.init $(1)/etc/init.d/asterisk
|
||||
$(INSTALL_CONF) ./files/asterisk.conf $(1)/etc/config/asterisk
|
||||
|
|
|
@ -1,26 +1,16 @@
|
|||
# The init script will create below default directories automatically.
|
||||
# In case you change these paths in your Asterisk configuration, make
|
||||
# sure that your directories exist and have the appropriate permissions
|
||||
# (Asterisk will use the user "asterisk", not root).
|
||||
|
||||
# dbdir => '/var/lib/asterisk/astdb'
|
||||
# logdir => '/var/log/asterisk'
|
||||
# rundir => '/var/run/asterisk'
|
||||
# spooldir => '/var/spool/asterisk'
|
||||
# varlibdir => '/var/lib/asterisk'
|
||||
|
||||
config asterisk 'general'
|
||||
option enabled '0'
|
||||
# If you have problems running Asterisk as user "asterisk" we'd
|
||||
# like to hear from you. Please raise an issue at:
|
||||
# https://github.com/openwrt/telephony/issues
|
||||
option user 'asterisk'
|
||||
option group 'asterisk'
|
||||
option log_stderr '1'
|
||||
option log_stdout '1'
|
||||
option options ''
|
||||
|
||||
config asterisk 'directories'
|
||||
# The init script will only create below directories and update
|
||||
# their permissions if they don't exist.
|
||||
# Note: To change the default paths you need to update your
|
||||
# "asterisk.conf" file.
|
||||
option agidir '/usr/share/asterisk/agi-bin'
|
||||
option datadir '/usr/share/asterisk'
|
||||
option dbdir '/var/lib/asterisk/astdb'
|
||||
option keydir '/usr/share/asterisk/keys'
|
||||
option logdir '/var/log/asterisk'
|
||||
option rundir '/var/run/asterisk'
|
||||
option spooldir '/var/spool/asterisk'
|
||||
option varlibdir '/var/lib/asterisk'
|
||||
|
||||
|
|
|
@ -13,25 +13,13 @@ COMMAND=/usr/sbin/$NAME
|
|||
LOGGER="/usr/bin/logger -p user.err -s -t $NAME --"
|
||||
|
||||
start_service() {
|
||||
local enabled
|
||||
|
||||
local user
|
||||
local group
|
||||
|
||||
local log_stderr
|
||||
local log_stdout
|
||||
|
||||
local agidir
|
||||
local cdrcsvdir
|
||||
local datadir
|
||||
local dbdir
|
||||
local keydir
|
||||
local logdir
|
||||
local rundir
|
||||
local spooldir
|
||||
local varlibdir
|
||||
|
||||
local options
|
||||
dbdir=/var/lib/asterisk/astdb
|
||||
logdir=/var/log/asterisk
|
||||
cdrcsvdir=$logdir/cdr-csv
|
||||
rundir=/var/run/asterisk
|
||||
spooldir=/var/spool/asterisk
|
||||
varlibdir=/var/lib/asterisk
|
||||
|
||||
config_load $NAME
|
||||
|
||||
|
@ -41,85 +29,30 @@ start_service() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
config_get user general user $NAME
|
||||
config_get group general group $NAME
|
||||
|
||||
user_exists "$user" || {
|
||||
$LOGGER user \""$user"\" does not exist
|
||||
exit 1
|
||||
}
|
||||
group_exists "$group" || {
|
||||
$LOGGER group \""$group"\" does not exist
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$user" = $NAME ]; then
|
||||
if ! id -nG $NAME | grep -qwF dialout; then
|
||||
group_exists dialout && group_add_user dialout $NAME
|
||||
fi
|
||||
fi
|
||||
|
||||
config_get_bool log_stderr general log_stderr 1
|
||||
config_get_bool log_stdout general log_stdout 1
|
||||
|
||||
config_get agidir directories agidir /usr/share/$NAME/agi-bin
|
||||
config_get datadir directories datadir /usr/share/$NAME
|
||||
config_get dbdir directories dbdir /var/lib/$NAME/astdb
|
||||
config_get keydir directories keydir /usr/share/$NAME/keys
|
||||
config_get logdir directories logdir /var/log/$NAME
|
||||
config_get rundir directories rundir /var/run/$NAME
|
||||
config_get spooldir directories spooldir /var/spool/$NAME
|
||||
config_get varlibdir directories varlibdir /var/lib/$NAME
|
||||
|
||||
config_get options general options
|
||||
|
||||
cdrcsvdir="${logdir}/cdr-csv"
|
||||
|
||||
# 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="$agidir" \
|
||||
-v b="$cdrcsvdir" \
|
||||
-v c="$datadir" \
|
||||
-v d="$dbdir" \
|
||||
-v e="$keydir" \
|
||||
-v f="$logdir" \
|
||||
-v g="$rundir" \
|
||||
-v h="$spooldir" \
|
||||
-v i="$varlibdir" \
|
||||
'
|
||||
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
|
||||
dir[8]=i
|
||||
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] "\"" )
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
chown -R "$user":"$group" /etc/$NAME
|
||||
for i in \
|
||||
"$logdir" \
|
||||
"$cdrcsvdir" \
|
||||
"$rundir" \
|
||||
"$spooldir" \
|
||||
"$varlibdir" \
|
||||
"$dbdir"
|
||||
do
|
||||
if ! [ -e "$i" ]; then
|
||||
mkdir -m 0750 -p "$i"
|
||||
[ -d "$i" ] && chown $NAME:$NAME "$i"
|
||||
fi
|
||||
done
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $COMMAND
|
||||
procd_append_param command \
|
||||
-G "$group" \
|
||||
-U "$user" \
|
||||
-G "$NAME" \
|
||||
-U "$NAME" \
|
||||
$options \
|
||||
-f
|
||||
# forward stderr to logd
|
||||
|
@ -127,5 +60,5 @@ start_service() {
|
|||
# same for stdout
|
||||
procd_set_param stdout $log_stdout
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue