source: trunk/netservices/slims/common/var/install/config.d/slims.sh@ 110302

Last change on this file since 110302 was 110302, checked in by jed, 2 months ago

changed /sbin/nologin to /usr/sbin/nologin path.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 40.9 KB
Line 
1#!/usr/bin/sh
2#----------------------------------------------------------------------------------------
3# /var/install/config.d/slims.sh - configuration generator script for slimserver
4#
5# Copyright (c) 2006-2024 The Eisfair Team, team(at)eisfair(dot)org
6#
7# Creation: 2006-06-05 jed
8# Last Update: $Id: slims.sh 110302 2024-04-19 10:57:12Z jed $
9#
10# Usage: slims.sh [--noconfirm][--quiet] command
11#
12# List of available commands/switches:
13# ** without command ** - generate configuration files
14#
15# --noconfirm - don't show any confirmation configlog screen
16# --quiet - suppress all screen output
17#
18# --version - show package version
19# --uninstalluser - remove slims user
20# --testconfig - create test configuration in /tmp
21#
22# This program is free software; you can redistribute it and/or modify
23# it under the terms of the GNU General Public License as published by
24# the Free Software Foundation; either version 2 of the License, or
25# (at your option) any later version.
26#----------------------------------------------------------------------------------------
27
28# read eislib etc.
29. /var/install/include/eislib
30. /var/install/include/jedlib
31
32# debug mode: true/false
33 debug=true
34if ${debug:-false}
35then
36 exec 2>/tmp/$(basename ${0})-trace$$.log
37 set -x
38 ask_debug=true
39 export ask_debug
40fi
41
42pgmname=`basename $0`
43module_name=`basename -s .sh ${pgmname} | cut -d- -f1`
44
45### set directory names ###
46systemlog_path=/var/log
47slims_spoolpath=/var/slims
48slims_program_path=/usr/share/squeezeboxserver
49slims_prefs_path=${slims_spoolpath}/prefs
50slims_prefs_plugin_path=${slims_prefs_path}/plugin
51slims_signal_path=${slims_spoolpath}/signals
52slims_cachedir=${slims_spoolpath}/cache
53slims_logdir=${slims_spoolpath}/log
54
55slims_user='slims'
56slims_group='nogroup'
57slims_gid=''
58
59servicesfile=/etc/services.slims
60slimsfile=/etc/config.d/slims
61slims_configfile=/var/install/config.d/slims.sh
62packagefile=/var/install/packages/slims
63configlog_file=${slims_logdir}/slims-configlog
64generate_slimsconf=${slims_prefs_path}/server.prefs
65generate_slimsconf_tmp=${slims_prefs_path}/server.prefs.tmp
66generate_cliconf=${slims_prefs_plugin_path}/cli.prefs
67generate_logrotate=/etc/logrotate.d/slims
68sedcmdfile=${slims_prefs_path}/slims-sedcmds.$$
69slims_audio_ownership=${slims_spoolpath}/slims-audio-ownership
70slims_audio_skip_set_of_ownership=${slims_spoolpath}/slims-audio-skip-set-of-ownership
71
72### other parameters ###
73slims_version="v`grep "<version>" ${packagefile} | sed 's#<version>\(.*\)</version>#\1#'`"
74
75### load configuration ###
76. ${slimsfile}
77chmod 600 ${slimsfile}
78
79#----------------------------------------------------------------------------------
80# show wait
81#----------------------------------------------------------------------------------
82show_wait ()
83{
84 local _sw_colpos
85
86 myecho --pack ${module_name} --force-output -n " wait [ "
87 _sw_colpos=1
88 while [ -n "`ps --no-headers $!`" ]
89 do
90 myecho --pack ${module_name} --force-output --info -n "."
91 sleep 1
92 _sw_colpos=`expr ${_sw_colpos} + 1`
93
94 if [ "${_sw_colpos}" -ge 52 ]
95 then
96 myecho --pack ${module_name} --force-output " ]"
97 myecho --pack ${module_name} --force-output -n " wait [ "
98 _sw_colpos=1
99 fi
100 done
101
102 if [ ${_sw_colpos} -eq 1 ]
103 then
104 myecho --pack ${module_name} --force-output --info -n "."
105 fi
106
107 myecho --pack ${module_name} --force-output " ] "
108}
109
110#----------------------------------------------------------------------------------------
111# check if directories exist
112# input : $1 - username
113# $2 - groupname
114# $3 - optional audio username
115# $4 - optional audio groupname
116#----------------------------------------------------------------------------------------
117check_directories ()
118{
119 local _cd_uname
120 local _cd_gname
121 local _cd_audio_uname
122 local _cd_audio_gname
123 local _cd_answer
124
125 _cd_uname="$1"
126 _cd_gname="$2"
127 _cd_audio_uname="$3"
128 _cd_audio_gname="$4"
129
130 if [ -z "${_cd_audio_uname}" ]
131 then
132 _cd_audio_uname="${_cd_uname}"
133 fi
134
135 if [ -z "${_cd_audio_gname}" ]
136 then
137 _cd_audio_gname="${_cd_gname}"
138 fi
139
140 for DNAME in ${slims_spoolpath} ${slims_cachedir} ${slims_logdir} ${slims_prefs_path} ${slims_prefs_plugin_path} ${slims_signal_path}
141 do
142 if [ ! -d ${DNAME} ]
143 then
144 mkdir -p ${DNAME}
145 fi
146
147 chown -R ${_cd_uname}: ${DNAME}
148 done
149
150 # make sure that the temporary slims directory is owned by the right user
151 if [ -d /tmp/par-slims ]
152 then
153 chown -R ${_cd_uname}: /tmp/par-slims
154 fi
155
156 # directories can be changed by user
157 for DNAME in ${SLIMS_COVER_PATH} ${SLIMS_PLAYLIST_PATH}
158 do
159 if [ ! -d ${DNAME} ]
160 then
161 mkdir -p ${DNAME}
162 fi
163
164 chown -R ${_cd_uname}: ${DNAME}
165 done
166
167 # handle audio path separately to prevent erroneous misconfiguration
168 # of directory/file ownership
169 if [ ! -d ${SLIMS_AUDIO_PATH} ]
170 then
171 mkdir -p ${SLIMS_AUDIO_PATH}
172 fi
173
174 # make sure a marker is set and an inital run is initiated
175 if [ ! -f ${slims_audio_ownership} ]
176 then
177 date -d 'yesterday' +'%Y%m%d' > ${slims_audio_ownership}
178 fi
179
180 if [ "${START_SLIMS}" = 'yes' ]
181 then
182 if [ ! -f ${slims_audio_skip_set_of_ownership} ]
183 then
184 myecho --pack ${module_name} ""
185 myecho --pack ${module_name} --info "The parameter SLIMS_AUDIO_PATH has been set to '${SLIMS_AUDIO_PATH}'."
186 myecho --pack ${module_name} --info "Slimserver needs to change the relevant directory/file ownership to"
187 myecho --pack ${module_name} --info "uid '${_cd_audio_uname}' and gid '${_cd_audio_gname}' to work properly."
188
189 _cd_answer='no'
190 if [ "${noconfirm}" = 'noconfirm' ]
191 then
192 # make sure that the ownership is at least set once per day
193 if [ "`date +'%Y%m%d'`" != "`cat ${slims_audio_ownership}`" ]
194 then
195 # dates differ, force setting ownership
196 _cd_answer='yes'
197 fi
198 else
199 # interactive mode
200 if /var/install/bin/ask "Do you allow to set the ownership now" "n"
201 then
202 _cd_answer='yes'
203 fi
204 fi
205
206 if [ "${_cd_answer}" = 'yes' ]
207 then
208 myecho --pack ${module_name} --force-output "- updating directory/file ownerships for path '${SLIMS_AUDIO_PATH}'."
209
210 chown -R ${_cd_audio_uname}:${_cd_audio_gname} ${SLIMS_AUDIO_PATH} &
211
212 # entertain the user
213 show_wait
214
215 # evaluate exit code
216 wait $!
217
218 # update the marker
219 date +'%Y%m%d' > ${slims_audio_ownership}
220 else
221 myecho --pack ${module_name} --warn "- Directory/file ownerships haven't been set!"
222 fi
223 else
224 myecho --pack ${module_name} --warn "- Setting of directory/file ownerships for path '${SLIMS_AUDIO_PATH}' skipped!"
225 fi
226 fi
227}
228
229#----------------------------------------------------------------------------------------
230# adding slimserver service
231#----------------------------------------------------------------------------------------
232add_slims_service ()
233{
234 if [ "${START_SLIMS}" = "yes" ]
235 then
236 myecho --pack ${module_name} "adding slimserver service ..."
237
238 {
239 echo '#'
240 echo "# ${servicesfile} list file generated by $0 ${slims_version}"
241 echo '#'
242 echo "slimcomm 3483/tcp # slimserver - discovery/communication"
243 echo "slimdisc 3483/udp # slimserver - discovery/communication"
244 echo "slimmusic 9090/tcp # slimserver - music library access"
245 echo "slim ${SLIMS_LISTEN_PORT}/tcp # slimserver - audio stream playback"
246 echo "mdns 5353/udp # Multicast DNS daemon"
247 } > ${servicesfile}
248
249 /var/install/bin/update-services slims
250 else
251 if [ -f ${servicesfile} ]
252 then
253 rm -f ${servicesfile}
254 /var/install/bin/update-services ${module_name}
255 fi
256 fi
257}
258
259#----------------------------------------------------------------------------------------
260# remove slims user
261#----------------------------------------------------------------------------------------
262remove_slims_user ()
263{
264 myecho --pack ${module_name} "removing slimserver user ..."
265
266 if getent passwd ${slims_user} >/dev/null 2>&1
267 then
268 # user exists, delete it
269 # parameter: -f (force) [user][remove homedir yes/no]
270 /var/install/bin/remove-user -f "${slims_user}" "yes"
271 fi
272}
273
274#----------------------------------------------------------------------------------------
275# check system user settings
276# input: $1 - username
277# $2 - uid -> '' - no check
278# $3 - gid -> '' - no check
279# $4 - shell -> '' - no check
280# $5 - password status -> '' - no check, 'invalid' - check
281#----------------------------------------------------------------------------------------
282check_system_user ()
283{
284 local _csu_user
285 local _csu_uid
286 local _csu_gid
287 local _csu_shell
288 local _csu_pass
289 local _csu_uidname
290 local _csu_gidname
291 local _csu_group
292 local _csu_add_groups
293 local _csu_ifs
294 local _csu_sname
295 local _csu_pword
296 local _csu_tmp_file=`mktemp -t ${module_name}.XXXXXXXXX`
297
298 # exim:x:42:42:exim:/home/exim:/bin/false
299 # trusted:x:42:
300 # exim:*:8902:0:10000::::
301 _csu_user="$1"
302 _csu_uid="$2"
303 _csu_gid="$3"
304 _csu_shell="$4"
305 _csu_pass="$5"
306
307 if getent passwd ${_csu_user} >/dev/null 2>&1
308 then
309 myecho --pack ${module_name} "checking settings of user '${_csu_user}' ..."
310
311 if [ -n "${_csu_uid}" ]
312 then
313 # user exists, check if group has properly been set
314 _csu_uidname=`getent passwd ${_csu_user} | cut -d: -f3`
315
316 if [ "${_csu_uidname}" != "${_csu_uid}" ]
317 then
318 write_to_config_log --warn "Attention, user-id of user '${_csu_user}' is not '${_csu_uid}' anymore!"
319 write_to_config_log --warn --ff "This might be a security leak!"
320 fi
321 fi
322
323 if [ -n "${_csu_gid}" ]
324 then
325 # user exists, check if group has properly been set
326 _csu_gidname=`getent passwd ${_csu_user} | cut -d: -f4`
327
328 if [ "${_csu_gidname}" != "${_csu_gid}" ]
329 then
330 _csu_group=`getent group ${_csu_gid} | cut -d: -f1`
331
332 write_to_config_log --warn "Attention, group of user '${_csu_user}' is not '${_csu_group}' anymore!"
333 write_to_config_log --warn --ff "This might be a security leak!"
334 fi
335
336 # grep all potential lines which might contain the user
337 getent group | grep "^.*:.*:.*[:,]*${_csu_user}[,$]*" > ${_csu_tmp_file}
338
339 _csu_add_groups=''
340 while read LINE
341 do
342 _csu_ifs="$IFS"
343 IFS=':'
344 set -- ${LINE}
345 _csu_group="$1"
346 _csu_add_user=`echo "$4" | sed 's/,/ /g'`
347 IFS=${_csu_ifs}
348
349 if [ -n "${_csu_add_user}" ]
350 then
351 # loop through list of users ...
352 for USR in ${_csu_add_user}
353 do
354 # match found, add group name to list
355 if [ "${USR}" = "${_csu_user}" ]
356 then
357 if [ -z "${_csu_add_groups}" ]
358 then
359 _csu_add_groups="${_csu_group}"
360 else
361 _csu_add_groups="${_csu_add_groups},${_csu_group}"
362 fi
363
364 break
365 fi
366 done
367 fi
368 done < ${_csu_tmp_file}
369
370 rm -f ${_csu_tmp_file}
371
372 if [ -n "${_csu_add_groups}" ]
373 then
374 write_to_config_log --warn "Attention, user '${_csu_user}' is member of additional group(s) '${_csu_add_groups}'!"
375 write_to_config_log --warn --ff "This might be a security leak!"
376 fi
377 fi
378
379 if [ -n "${_csu_shell}" ]
380 then
381 # user exists, check if shell has properly been set
382 _csu_sname=`getent passwd ${_csu_user} | cut -d: -f7`
383
384 if [ "${_csu_sname}" != "${_csu_shell}" ]
385 then
386 write_to_config_log --warn "Attention, shell of user '${_csu_user}' is not '${_csu_shell}' anymore!"
387 write_to_config_log --warn --ff "This might be a security leak!"
388 fi
389 fi
390
391 if [ "${_csu_pass}" = "invalid" ]
392 then
393 # user exists, check if password has been invalidated
394 _csu_pword=`getent shadow ${_csu_user} | cut -d: -f2`
395
396 [ "${_csu_pword}" != '*' ] && ! echo "${_csu_pword}" | grep -q "^!"
397
398 if [ $? -eq 0 ]
399 then
400 write_to_config_log --warn "Attention, password of user '${_csu_user}' is not invalidated anymore!"
401 write_to_config_log --warn --ff "This might be a security leak!"
402 fi
403 fi
404 else
405 write_to_config_log --error "System user '${_csu_user}' doesn't exist!"
406 fi
407}
408
409#----------------------------------------------------------------------------------------
410# create logrotate file
411# input : $1 - username
412# $2 - groupname
413#----------------------------------------------------------------------------------------
414create_logrotate ()
415{
416 local _cl_uname
417 local _cl_gname
418
419 _cl_uname="$1"
420 _cl_gname="$2"
421
422 myecho --pack ${module_name} "creating logrotate configuration file ..."
423
424 {
425 #----------------------------------------------------------------------------------------
426 print_short_header "${generate_logrotate}" "${pgmname}" "${slims_version}"
427 #----------------------------------------------------------------------------------------
428
429 if [ "${START_SLIMS}" = "yes" ]
430 then
431 echo "${slims_logdir}/slimserver.log {"
432 echo " prerotate"
433 echo " /usr/sbin/service --quiet stop ${module_name}"
434 echo " endscript"
435
436 echo " rotate ${SLIMS_LOG_COUNT}"
437 echo " ${SLIMS_LOG_INTERVAL}"
438 echo " compress"
439 echo " missingok"
440 echo " notifempty"
441 echo " create 640 ${_cl_uname} ${_cl_gname}"
442
443 echo " postrotate"
444 echo " /usr/sbin/service --quiet start ${module_name}"
445 echo " endscript"
446 echo " }"
447 echo
448 else
449 echo "# Slims disabled!"
450 fi
451 } > ${generate_logrotate}
452}
453
454#----------------------------------------------------------------------------------------
455# create slimserver configuration
456#----------------------------------------------------------------------------------------
457create_slims_config ()
458{
459 local _csc_client_params
460
461 myecho --pack ${module_name} "creating slimserver configuration file ..."
462
463 # backup existing configuration
464 /var/install/bin/backup-file --quiet ${generate_slimsconf} backup
465
466 echo "${SLIMS_ALLOWED_ADDRESSES}" | grep -q "127.0.0.1"
467
468 if [ $? -ne 0 ]
469 then
470 SLIMS_ALLOWED_ADDRESSES="127.0.0.1,${SLIMS_ALLOWED_ADDRESSES}"
471 fi
472
473 myecho --pack ${module_name} "- access allowed from: ${SLIMS_ALLOWED_ADDRESSES}"
474 {
475 #----------------------------------------------------------------------------------------
476 # print_short_header "${generate_slimsconf}" "${pgmname}" "${slims_version}"
477 #----------------------------------------------------------------------------------------
478
479 echo "---"
480
481 ### begin of individual client parameters ###
482 _csc_client_params=0
483 if [ ${_csc_client_params} -eq 1 ]
484 then
485 echo "_client:00:04:20:06:70:97: "
486 # echo " _ts_activeFont: 1221241734"
487 # echo " _ts_activeFont_curr: 1221241734"
488 # echo " _ts_alarm: 1221241734"
489 # echo " _ts_alarmfadeseconds: 1221241734"
490 # echo " _ts_alarmplaylist: 1221241734"
491 # echo " _ts_alarmtime: 1221241734"
492 # echo " _ts_alarmvolume: 1221241734"
493 # echo " _ts_autobrightness: 1221241734"
494 # echo " _ts_bass: 1221241734"
495 # echo " _ts_bufferThreshold: 1221241734"
496 # echo " _ts_currentSong: 1223832380"
497 # echo " _ts_digitalVolumeControl: 1221241734"
498 # echo " _ts_disableDac: 1221241734"
499 # echo " _ts_disabledirsets: 1221241734"
500 # echo " _ts_doublesize: 1221241734"
501 # echo " _ts_idleBrightness: 1221241734"
502 # echo " _ts_idleFont: 1221241734"
503 # echo " _ts_idleFont_curr: 1221241734"
504 # echo " _ts_idlesaver: 1221241734"
505 # echo " _ts_irmap: 1221241734"
506 # echo " _ts_lameQuality: 1221241734"
507 # echo " _ts_largeTextFont: 1221241734"
508 # echo " _ts_maintainSync: 1221241734"
509 # echo " _ts_maxBitrate: 1221241734"
510 # echo " _ts_menuItem: 1221241734"
511 # echo " _ts_minSyncAdjust: 1221241734"
512 # echo " _ts_mp3SilencePrelude: 1221241734"
513 # echo " _ts_offDisplaySize: 1221241734"
514 # echo " _ts_offsaver: 1221241734"
515 # echo " _ts_packetLatency: 1221241734"
516 # echo " _ts_pitch: 1221241734"
517 # echo " _ts_playDelay: 1221241734"
518 # echo " _ts_playername: 1221241734"
519 # echo " _ts_playingAtPowerOff: 1221241734"
520 # echo " _ts_playingDisplayMode: 1221241734"
521 # echo " _ts_playingDisplayModes: 1221241734"
522 # echo " _ts_playtrackalbum: 1221241734"
523 # echo " _ts_power: 1221241734"
524 # echo " _ts_powerOffBrightness: 1221241734"
525 # echo " _ts_powerOnBrightness: 1221241734"
526 # echo " _ts_powerOnResume: 1221241734"
527 # echo " _ts_preampVolumeControl: 1221241734"
528 # echo " _ts_repeat: 1221241734"
529 # echo " _ts_replayGainMode: 1221241734"
530 # echo " _ts_screensaver: 1221241734"
531 # echo " _ts_screensavertimeout: 1221241734"
532 # echo " _ts_scrollMode: 1221241734"
533 # echo " _ts_scrollPause: 1221241734"
534 # echo " _ts_scrollPauseDouble: 1221241734"
535 # echo " _ts_scrollPixels: 1221241734"
536 # echo " _ts_scrollPixelsDouble: 1221241734"
537 # echo " _ts_scrollRate: 1221241734"
538 # echo " _ts_scrollRateDouble: 1221241734"
539 # echo " _ts_shuffle: 1221241734"
540 # echo " _ts_snLastSyncDown: 1221241734"
541 # echo " _ts_snLastSyncUp: 1221241734"
542 # echo " _ts_snSyncInterval: 1221241734"
543 # echo " _ts_startDelay: 1221241734"
544 # echo " _ts_syncBufferThreshold: 1221241734"
545 # echo " _ts_syncPower: 1221241734"
546 # echo " _ts_syncVolume: 1221241734"
547 # echo " _ts_titleFormat: 1221241734"
548 # echo " _ts_titleFormatCurr: 1221241734"
549 # echo " _ts_transitionDuration: 1221241734"
550 # echo " _ts_transitionSmart: 1221241734"
551 # echo " _ts_transitionType: 1221241734"
552 # echo " _ts_treble: 1221241734"
553 # echo " _ts_volume: 1221241734"
554 echo " _version: 9"
555
556 echo " alarmDefaultVolume: 50"
557 echo " alarmSnoozeSeconds: 540"
558 echo " alarmTimeoutSeconds: 3600"
559 echo " alarmfadeseconds: 1"
560 echo " alarms: {}"
561 echo
562 echo " alarmsEnabled: 0"
563 echo " alarmsaver: SCREENSAVER.datetime"
564 echo " alwaysShowCount: 1"
565 # echo " activeFont: "
566 # echo " - light"
567 # echo " - standard"
568 # echo " - full"
569 # echo " - high"
570 # echo " activeFont_curr: 1"
571 # echo " alarm: "
572 # echo " - 0"
573 # echo " - 0"
574 # echo " - 0"
575 # echo " - 0"
576 # echo " - 0"
577 # echo " - 0"
578 # echo " - 0"
579 # echo " - 0"
580 # echo " alarmfadeseconds: 0"
581 # echo " alarmplaylist: "
582 # echo " - ''"
583 # echo " - ''"
584 # echo " - ''"
585 # echo " - ''"
586 # echo " - ''"
587 # echo " - ''"
588 # echo " - ''"
589 # echo " - ''"
590 # echo " alarmtime: "
591 # echo " - 0"
592 # echo " - 0"
593 # echo " - 0"
594 # echo " - 0"
595 # echo " - 0"
596 # echo " - 0"
597 # echo " - 0"
598 # echo " - 0"
599 # echo " alarmvolume: "
600 # echo " - 50"
601 # echo " - 50"
602 # echo " - 50"
603 # echo " - 50"
604 # echo " - 50"
605 # echo " - 50"
606 # echo " - 50"
607 # echo " - 50"
608 # echo " autobrightness: 1"
609 echo " bass: 50"
610 echo " bufferThreshold: 255"
611 echo " currentSong: 0"
612 echo " digitalVolumeControl: 1"
613 echo " disableDac: 0"
614 echo " disabledirsets: []"
615 echo
616 # echo " - jvc_dvd.ir"
617 # echo " doublesize: 0"
618 echo " idleBrightness: 2"
619 # echo " idleFont: "
620 # echo " - light"
621 # echo " - standard"
622 # echo " - full"
623 # echo " idleFont_curr: 1"
624 echo " idlesaver: nosaver"
625 echo " irmap: ${slims_program_path}/IR/Default.map"
626 echo " lameQuality: 9"
627 # echo " largeTextFont: 1"
628 echo " maintainSync: 1"
629 echo " maxBitrate: ~"
630 echo " menuItem: "
631 echo " - NOW_PLAYING"
632 echo " - BROWSE_MUSIC"
633 echo " - RADIO"
634 echo " - MUSIC_SERVICES"
635 echo " - FAVORITES"
636 echo " - PLUGINS"
637 echo " - SETTINGS"
638 echo " minSyncAdjust: 30"
639 echo " mp3SilencePrelude: 0"
640 echo " offDisplaySize: 0"
641 echo " offsaver: SCREENSAVER.datetime"
642 echo " packetLatency: 2"
643 echo " pitch: 100"
644 echo " playDelay: 0"
645 echo " playername: ~"
646 echo " playingAtPowerOff: ''"
647 echo " playingDisplayMode: 4"
648 echo " playingDisplayModes: "
649 echo " - 0"
650 echo " - 1"
651 echo " - 2"
652 echo " - 3"
653 echo " - 4"
654 echo " - 5"
655 echo " - 6"
656 echo " - 7"
657 echo " - 8"
658 echo " - 9"
659 echo " - 10"
660 echo " - 11"
661 echo " playtrackalbum: 1"
662 echo " power: 0"
663 echo " powerOffBrightness: 1"
664 echo " powerOnBrightness: 4"
665 echo " powerOnResume: PauseOff-NoneOn"
666 echo " preampVolumeControl: 0"
667 echo " presets:"
668 echo " - ~"
669 echo " - ~"
670 echo " - ~"
671 echo " - ~"
672 echo " - ~"
673 echo " - ~"
674 echo " - ~"
675 echo " - ~"
676 echo " - ~"
677 echo " - ~"
678 echo " repeat: 0"
679 echo " replayGainMode: 3"
680 echo " screensaver: playlist"
681 echo " screensavertimeout: 30"
682 echo " scrollMode: 0"
683 echo " scrollPause: 3.6"
684 echo " scrollPauseDouble: 3.6"
685 echo " scrollRate: 0.15"
686 echo " scrollRateDouble: 0.1"
687 echo " shuffle: 1"
688 echo " snLastSyncDown: -1"
689 echo " snLastSyncUp: -1"
690 echo " snSyncInterval: 30"
691 echo " startDelay: 0"
692 echo " syncPower: 0"
693 echo " syncVolume: 0"
694 echo " titleFormat: "
695 echo " - 5"
696 echo " - 1"
697 echo " - 3"
698 echo " - 6"
699 echo " - 0"
700 echo " titleFormatCurr: 0"
701 echo " transitionDuration: 0"
702 echo " transitionSmart: 1"
703 echo " transitionType: 0"
704 echo " treble: 50"
705 echo " volume: 72"
706 fi
707 ### end of individual client parameters ###
708
709 ### begin of global parameters ###
710 # echo "_ts_allowedHosts: 1221241724"
711 # echo "_ts_artfolder: 1221241724"
712 # echo "_ts_audiodir: 1223832379"
713 # echo "_ts_authorize: 1221241724"
714 # echo "_ts_bandInArtists: 1221241724"
715 # echo "_ts_bindAddress: 1221241724"
716 # echo "_ts_browseagelimit: 1221241724"
717 # echo "_ts_bufferSecs: 1221241724"
718 # echo "_ts_cachedir: 1221241724"
719 # echo "_ts_checkVersion: 1221241724"
720 # echo "_ts_checkVersionInterval: 1221241724"
721 # echo "_ts_composerInArtists: 1221241724"
722 # echo "_ts_conductorInArtists: 1221241724"
723 # echo "_ts_coverArt: 1221241724"
724 # echo "_ts_csrfProtectionLevel: 1221241724"
725 # echo "_ts_dbpassword: 1221241724"
726 # echo "_ts_dbsource: 1221241724"
727 # echo "_ts_dbusername: 1221241724"
728 # echo "_ts_disableStatistics: 1221241724"
729 # echo "_ts_disabledextensionsaudio: 1221241724"
730 # echo "_ts_disabledextensionsplaylist: 1221241724"
731 # echo "_ts_disabledformats: 1221241724"
732 # echo "_ts_displaytexttimeout: 1221241724"
733 # echo "_ts_filterHosts: 1221241724"
734 # echo "_ts_groupdiscs: 1221241724"
735 # echo "_ts_guessFileFormats: 1221241724"
736 # echo "_ts_httpport: 1221241724"
737 # echo "_ts_ignoreDirRE: 1221241724"
738 # echo "_ts_ignoredarticles: 1221241724"
739 # echo "_ts_itemsPerPage: 1221241724"
740 # echo "_ts_jivealbumsort: 1221241724"
741 # echo "_ts_language: 1223832111"
742 # echo "_ts_loadFontsSqueezebox2: 1221241734"
743 # echo "_ts_loadFontsText: 1221241739"
744 # echo "_ts_longdateFormat: 1223832111"
745 # echo "_ts_mDNSname: 1221241724"
746 # echo "_ts_maxWMArate: 1221241724"
747 # echo "_ts_noGenreFilter: 1221241724"
748 # echo "_ts_noupnp: 1221241724"
749 # echo "_ts_password: 1221241724"
750 # echo "_ts_persistPlaylists: 1221241724"
751 # echo "_ts_playlistdir: 1221241724"
752 # echo "_ts_playtrackalbum: 1221241724"
753 # echo "_ts_precacheArtwork: 1221241724"
754 # echo "_ts_rank-BROWSE_BY_ALBUM: 1221241724"
755 # echo "_ts_rank-BROWSE_BY_ARTIST: 1221241724"
756 # echo "_ts_rank-BROWSE_BY_GENRE: 1221241724"
757 # echo "_ts_rank-BROWSE_BY_YEAR: 1221241724"
758 # echo "_ts_rank-BROWSE_MUSIC_FOLDER: 1221241724"
759 # echo "_ts_rank-BROWSE_NEW_MUSIC: 1221241724"
760 # echo "_ts_rank-GAMES: 1221241724"
761 # echo "_ts_rank-PLUGIN_LIVE365_MODULE_NAME: 1221241724"
762 # echo "_ts_rank-PLUGIN_LMA_MODULE_NAME: 1221241724"
763 # echo "_ts_rank-PLUGIN_MP3TUNES_MODULE_NAME: 1221241724"
764 # echo "_ts_rank-PLUGIN_PANDORA_MODULE_NAME: 1221241724"
765 # echo "_ts_rank-PLUGIN_PICKS_MODULE_NAME: 1221241724"
766 # echo "_ts_rank-PLUGIN_PODCAST: 1221241724"
767 # echo "_ts_rank-PLUGIN_RADIOIO_MODULE_NAME: 1221241724"
768 # echo "_ts_rank-PLUGIN_RADIOTIME_MODULE_NAME: 1221241724"
769 # echo "_ts_rank-PLUGIN_RANDOMPLAY: 1221241724"
770 # echo "_ts_rank-PLUGIN_RHAPSODY_DIRECT_MODULE_NAME: 1221241724"
771 # echo "_ts_rank-PLUGIN_RSSNEWS: 1221241724"
772 # echo "_ts_rank-PLUGIN_SHOUTCASTBROWSER_MODULE_NAME: 1221241724"
773 # echo "_ts_rank-PLUGIN_SLACKER_MODULE_NAME: 1221241724"
774 # echo "_ts_rank-PLUGIN_SOUNDS_MODULE_NAME: 1221241724"
775 # echo "_ts_rank-SAVED_PLAYLISTS: 1221241724"
776 # echo "_ts_rank-SEARCH: 1221241724"
777 # echo "_ts_refreshRate: 1221241724"
778 # echo "_ts_remotestreamtimeout: 1221241724"
779 # echo "_ts_resampleArtwork: 1221241724"
780 # echo "_ts_reshuffleOnRepeat: 1221241724"
781 # echo "_ts_saveShuffled: 1221241724"
782 # echo "_ts_scannerPriority: 1221241724"
783 # echo "_ts_searchSubString: 1221241724"
784 # echo "_ts_securitySecret: 1221241724"
785 # echo "_ts_serverPriority: 1221241724"
786 # echo "_ts_shortdateFormat: 1223832111"
787 # echo "_ts_showArtist: 1221241724"
788 # echo "_ts_showYear: 1221241724"
789 # echo "_ts_skin: 1221241724"
790 # echo "_ts_sn_sync: 1221241724"
791 # echo "_ts_splitList: 1221241724"
792 # echo "_ts_tcpConnectMaximum: 1221241724"
793 # echo "_ts_thumbSize: 1221241724"
794 # echo "_ts_timeFormat: 1223832111"
795 # echo "_ts_titleFormat: 1221241724"
796 # echo "_ts_titleFormatWeb: 1221241724"
797 # echo "_ts_udpChunkSize: 1221241724"
798 # echo "_ts_useBandAsAlbumArtist: 1221241724"
799 # echo "_ts_useTPE2AsAlbumArtist: 1221241724"
800 # echo "_ts_username: 1221241724"
801 # echo "_ts_variousArtistAutoIdentification: 1221241724"
802 # echo "_ts_variousArtistsString: 1221241724"
803 # echo "_ts_webproxy: 1223832379"
804 # echo "_ts_wizardDone: 1223832379"
805 echo "_version: 8"
806
807 echo "allowedHosts: ${SLIMS_ALLOWED_ADDRESSES}"
808 echo "artfolder: ${SLIMS_COVER_PATH}"
809 echo "audiodir: ${SLIMS_AUDIO_PATH}"
810
811 if [ "${SLIMS_WEB_AUTH}" = "yes" ]
812 then
813 echo "authorize: 1"
814 else
815 echo "authorize: 0"
816 fi
817
818 echo "autoDownloadUpdate: 0"
819 echo "autorescan: 0"
820 echo "autorescan_stat_interval: 10"
821 echo "bandInArtists: 0"
822 echo "bindAddress: 127.0.0.1"
823 echo "browseagelimit: 100"
824 echo "bufferSecs: 3"
825 echo "cachedir: ${slims_cachedir}"
826 # disable slimserver version check
827 echo "checkVersion: 0"
828 echo "checkVersionInterval: 86400"
829
830 echo "composerInArtists: 0"
831 echo "conductorInArtists: 0"
832 # set name for cover art file
833 echo "coverArt: \"%ARTIST-ALBUM-cover.jpg\""
834 echo "csrfProtectionLevel: 1"
835 echo "dbhighmem: 0"
836 echo "dbpassword: ''"
837 echo "dbsource: dbi:SQLite:dbname=${slims_cachedir}/library.db"
838 echo "dbusername: ''"
839 echo "disableStatistics: 0"
840 echo "disabledextensionsaudio: ''"
841 echo "disabledextensionsplaylist: ''"
842 echo "disabledformats:"
843 echo ' - mpc-flc-*-*'
844 echo "displaytexttimeout: 1"
845 echo "filterHosts: 1"
846 echo "groupdiscs: 1"
847 echo "guessFileFormats: "
848 echo " - (ARTIST - ALBUM) TRACKNUM - TITLE"
849 echo " - /ARTIST/ALBUM/TRACKNUM - TITLE"
850 echo " - /ARTIST/ALBUM/TRACKNUM TITLE"
851 echo " - /ARTIST/ALBUM/TRACKNUM. TITLE"
852
853 if [ -z "${SLIMS_LISTEN_PORT}" ]
854 then
855 SLIMS_LISTEN_PORT='9000'
856 fi
857
858 echo "httpport: ${SLIMS_LISTEN_PORT}"
859 echo "ignoreDirRE: ''"
860 # added german articles
861 echo "ignoredarticles: The El La Los Las Le Les Der Die Das"
862 echo "itemsPerPage: 50"
863 echo "jivealbumsort: artistalbum"
864 # set default language to german
865 echo "language: DE"
866 echo "librarycachedir: ${slims_cachedir}"
867 echo "libraryname: My Music Archive (Hosted on eisfair)"
868 echo "loadFontsSqueezebox2: 1"
869 echo "loadFontsText: 1"
870 # german date Format: MONTAG, 3. JULI 2006
871 echo "longdateFormat: \"%A, |%d. %B %Y\""
872 # look for cover art
873 echo "mDNSname: SlimServer"
874 echo "maxPlaylistLength: 500"
875 echo "maxWMArate: 9999"
876 echo "noGenreFilter: 1"
877 echo "noupnp: 1"
878
879 # password not set, see also username: parameter
880 # echo "password: `openssl passwd -crypt "${SLIMS_WEB_PASS}"`"
881 echo "password: `/usr/bin/slims-crypt.pl "${SLIMS_WEB_PASS}"`"
882
883 echo "persistPlaylists: 1"
884 echo "playlistdir: ${SLIMS_PLAYLIST_PATH}"
885 echo "playtrackalbum: 1"
886 echo "precacheArtwork: 1"
887 echo "rank-BROWSE_BY_ALBUM: 30"
888 echo "rank-BROWSE_BY_ARTIST: 35"
889 echo "rank-BROWSE_BY_GENRE: 25"
890 echo "rank-BROWSE_BY_YEAR: 20"
891 echo "rank-BROWSE_MUSIC_FOLDER: 10"
892 echo "rank-BROWSE_NEW_MUSIC: 15"
893 echo "rank-GAMES: 20"
894 echo "rank-PLUGIN_LIVE365_MODULE_NAME: 10"
895 echo "rank-PLUGIN_LMA_MODULE_NAME: 5"
896 echo "rank-PLUGIN_MP3TUNES_MODULE_NAME: 10"
897 echo "rank-PLUGIN_PANDORA_MODULE_NAME: 25"
898 echo "rank-PLUGIN_PICKS_MODULE_NAME: 25"
899 echo "rank-PLUGIN_PODCAST: 35"
900 echo "rank-PLUGIN_RADIOIO_MODULE_NAME: 20"
901 echo "rank-PLUGIN_RADIOTIME_MODULE_NAME: 15"
902 echo "rank-PLUGIN_RANDOMPLAY: 13"
903 echo "rank-PLUGIN_RHAPSODY_DIRECT_MODULE_NAME: 20"
904 echo "rank-PLUGIN_RSSNEWS: 30"
905 echo "rank-PLUGIN_SHOUTCASTBROWSER_MODULE_NAME: 5"
906 echo "rank-PLUGIN_SLACKER_MODULE_NAME: 15"
907 echo "rank-PLUGIN_SOUNDS_MODULE_NAME: 25"
908 echo "rank-SAVED_PLAYLISTS: 5"
909 echo "rank-SEARCH: 3"
910 echo "ratingImplementation: LOCAL_RATING_STORAGE"
911
912 echo "refreshRate: 30"
913 echo "remotestreamtimeout: 10"
914 echo "resampleArtwork: 1"
915 echo "reshuffleOnRepeat: 1"
916 echo "saveShuffled: 0"
917 echo "scannerPriority: 0"
918 # search within sub strings
919 echo "searchSubString: 1"
920 echo "securitySecret: ''"
921 echo "serverPriority: ''"
922 echo "shortdateFormat: \"%d.%m.%Y\""
923 echo "showArtist: 1"
924 echo "showYear: 0"
925 echo "skin: Default"
926 echo "sn_disable_stats: 1"
927 echo "sn_sync: 1"
928 echo "splitList: ''"
929 echo "tcpConnectMaximum: 30"
930 echo "thumbSize: 150"
931 # german time format: 13:44:15
932 echo "timeFormat: \"%H:%M:%S\""
933 echo "titleFormat: "
934 echo " - TITLE"
935 echo " - DISC-TRACKNUM. TITLE"
936 echo " - TRACKNUM. TITLE"
937 echo " - TRACKNUM. ARTIST - TITLE"
938 echo " - TRACKNUM. TITLE (ARTIST)"
939 echo " - TRACKNUM. TITLE - ARTIST - ALBUM"
940 echo " - FILE.EXT"
941 echo " - TRACKNUM. TITLE from ALBUM by ARTIST"
942 echo " - TITLE (ARTIST)"
943 echo " - ARTIST - TITLE"
944 echo "titleFormatWeb: 4"
945 echo "udpChunkSize: 1400"
946 echo "useBandAsAlbumArtist: 0"
947 echo "useTPE2AsAlbumArtist: 0"
948 # username not set, see also password: parameter
949 echo "username: ${SLIMS_WEB_USER}"
950 echo "variousArtistAutoIdentification: 0"
951 echo "variousArtistsString: ''"
952 echo "webproxy: ${SLIMS_HTTP_PROXY}"
953 echo "wizardDone: 1"
954 } > ${generate_slimsconf}
955
956 chown ${slims_user} ${generate_slimsconf}
957 chgrp ${slims_group} ${generate_slimsconf}
958}
959
960#----------------------------------------------------------------------------------------
961# update slims configuration
962#----------------------------------------------------------------------------------------
963update_slims_config ()
964{
965 local _usc_web_auth
966
967 myecho --pack ${module_name} "updating slimserver configuration file ..."
968
969 # backup existing configuration
970 /var/install/bin/backup-file --quiet ${generate_slimsconf} backup
971
972 # allowed addresses
973 if [ -n "${SLIMS_ALLOWED_ADDRESSES}" ]
974 then
975 echo "${SLIMS_ALLOWED_ADDRESSES}" | grep -q "127.0.0.1"
976
977 if [ $? -ne 0 ]
978 then
979 SLIMS_ALLOWED_ADDRESSES="127.0.0.1,${SLIMS_ALLOWED_ADDRESSES}"
980 fi
981 else
982 SLIMS_ALLOWED_ADDRESSES="127.0.0.1"
983 fi
984
985 myecho --pack ${module_name} "- access allowed from: ${SLIMS_ALLOWED_ADDRESSES}"
986 echo "/^allowedHosts: /s/allowedHosts: .*$/allowedHosts: ${SLIMS_ALLOWED_ADDRESSES}/" > ${sedcmdfile}
987
988 # http listen port
989 if [ -z "${SLIMS_LISTEN_PORT}" ]
990 then
991 SLIMS_LISTEN_PORT='9000'
992 fi
993
994 myecho --pack ${module_name} "- http listen port: ${SLIMS_LISTEN_PORT}"
995 echo "/^httpport: /s/httpport: .*$/httpport: ${SLIMS_LISTEN_PORT}/" >> ${sedcmdfile}
996
997 # web authentication
998 if [ "${SLIMS_WEB_AUTH}" = "yes" ]
999 then
1000 _usc_web_auth='1'
1001 else
1002 _usc_web_auth='0'
1003 fi
1004
1005 myecho --pack ${module_name} "- web authentication: ${SLIMS_WEB_AUTH}"
1006 echo "/^authorize: /s/authorize: .*$/authorize: ${_usc_web_auth}/" >> ${sedcmdfile}
1007
1008 if [ "${SLIMS_WEB_AUTH}" = "yes" ]
1009 then
1010 # web username
1011 myecho --pack ${module_name} "- web username: ${SLIMS_WEB_USER}"
1012 echo "/^username: /s/username: .*$/username: ${SLIMS_WEB_USER}/" >> ${sedcmdfile}
1013
1014 # web password
1015 # echo "s|^password: .*$|password: `openssl passwd -crypt \"${SLIMS_WEB_PASS}\"`|" >> ${sedcmdfile}
1016 echo "s|^password: .*$|password: `/usr/bin/slims-crypt.pl \"${SLIMS_WEB_PASS}\"`|" >> ${sedcmdfile}
1017 fi
1018
1019 # web proxy
1020 if [ -z "${SLIMS_HTTP_PROXY}" ]
1021 then
1022 SLIMS_HTTP_PROXY='~'
1023 fi
1024
1025 myecho --pack ${module_name} "- http proxy: ${SLIMS_HTTP_PROXY}"
1026 echo "/^webproxy: /s/webproxy: .*$/webproxy: ${SLIMS_HTTP_PROXY}/" >> ${sedcmdfile}
1027
1028 # audio path
1029 myecho --pack ${module_name} "- audio path: ${SLIMS_AUDIO_PATH}"
1030 echo "s|^audiodir: .*$|audiodir: ${SLIMS_AUDIO_PATH}|" >> ${sedcmdfile}
1031
1032 # art folder
1033 myecho --pack ${module_name} "- artwork path: ${SLIMS_COVER_PATH}"
1034 echo "s|^artfolder: .*$.|artfolder: ${SLIMS_COVER_PATH}|" >> ${sedcmdfile}
1035
1036 # playlist path
1037 myecho --pack ${module_name} "- playlist path: ${SLIMS_PLAYLIST_PATH}"
1038 echo "s|^playlistdir: .*$|playlistdir: ${SLIMS_PLAYLIST_PATH}|" >> ${sedcmdfile}
1039
1040 sed -f ${sedcmdfile} ${generate_slimsconf} > ${generate_slimsconf_tmp}
1041 mv ${generate_slimsconf_tmp} ${generate_slimsconf}
1042
1043 chown ${slims_user} ${generate_slimsconf}
1044 chgrp ${slims_group} ${generate_slimsconf}
1045
1046 rm -f ${sedcmdfile}
1047}
1048
1049#----------------------------------------------------------------------------------------
1050# create cli-plugin configuration
1051#----------------------------------------------------------------------------------------
1052create_cli_plugin_config ()
1053{
1054 myecho --pack ${module_name} "creating cli-plugin configuration file ..."
1055
1056 # backup existing configuration
1057 /var/install/bin/backup-file --quiet ${generate_cliconf} backup
1058
1059 {
1060 #----------------------------------------------------------------------------------------
1061 # print_short_header "${generate_cliconf}" "${pgmname}" "${slims_version}"
1062 #----------------------------------------------------------------------------------------
1063
1064 echo "---"
1065 # echo "_ts_cliport: 1221241730"
1066 echo "_version: 1"
1067 echo "cliport: 9090"
1068 } > ${generate_cliconf}
1069
1070 chown ${slims_user} ${generate_cliconf}
1071 chgrp ${slims_group} ${generate_cliconf}
1072}
1073
1074#----------------------------------------------------------------------------------------
1075# print version
1076#----------------------------------------------------------------------------------------
1077print_version ()
1078{
1079 myecho --pack ${module_name} "${module_name} version: ${slims_version}"
1080}
1081
1082#========================================================================================
1083# Main
1084#========================================================================================
1085
1086noconfirm=''
1087force_quiet_run=false
1088if [ $# -gt 0 ]
1089then
1090 # read parameter(s)
1091 while [ $# -gt 0 ]
1092 do
1093 case $1 in
1094 *-noconfirm )
1095 noconfirm=noconfirm
1096 shift
1097 ;;
1098 *-quiet )
1099 force_quiet_run=true
1100 shift
1101 ;;
1102 * )
1103 cmd="$1"
1104 break
1105 ;;
1106 esac
1107 done
1108fi
1109
1110case ${cmd} in
1111 *-testconfig|testconfig )
1112 generate_slimsconf=/tmp/slims-server.prefs
1113
1114 myecho --pack ${module_name} "creating test configuration '${generate_slimsconf}' ..."
1115 create_slims_config
1116 myecho --pack ${module_name} "done."
1117 ;;
1118 *-uninstalluser|uninstalluser )
1119 remove_slims_user
1120 ;;
1121
1122 *-version|version )
1123 print_version
1124 ;;
1125
1126 * )
1127 # create slimserver configuration
1128 myecho --pack ${module_name} ""
1129 print_version
1130
1131 check_directories "${slims_user}" "${slims_group}" ${SLIMS_AUDIO_PATH_USER} ${SLIMS_AUDIO_PATH_GROUP}
1132
1133 write_to_config_log --header
1134
1135 check_system_user "${slims_user}" '' "${slims_gid}" '/usr/sbin/nologin' ''
1136
1137 add_slims_service
1138 create_logrotate "${slims_user}" "${slims_group}"
1139
1140 if [ "${SLIMS_MANUAL_CONFIGURATION}" = "no" -o ! -f ${generate_slimsconf} ]
1141 then
1142 create_slims_config
1143 create_cli_plugin_config
1144 else
1145 update_slims_config
1146
1147 write_to_config_log --info "Updated configuration file because parameter"
1148 write_to_config_log --warn --ff "SLIMS_MANUAL_CONFIGURATION='yes' has been set!"
1149 fi
1150
1151 # restart server to activate configuration changes
1152 /usr/sbin/service daemon-reload
1153 /usr/sbin/service stop ${module_name}
1154 sleep 4
1155 /usr/sbin/service start ${module_name}
1156
1157 compress_config_log
1158
1159 if [ "${noconfirm}" != 'noconfirm' ]
1160 then
1161 display_config_log
1162 fi
1163
1164 myecho --pack ${module_name} "finished."
1165 ;;
1166esac
1167
1168#========================================================================================
1169# End
1170#========================================================================================
1171exit 0
Note: See TracBrowser for help on using the repository browser.