# Common functions shared by LTSP init scripts # ltsp_config sources ltsp-client-functions . /usr/share/ltsp/ltsp_config warn() { msg="$1" logger -p user.warning -t ltsp-client "warning: $msg" } start_printers() { for I in 0 1 2; do eval PRINTER_DEVICE=\$\{PRINTER_${I}_DEVICE\} if [ -n "${PRINTER_DEVICE}" ]; then eval PORT=\$\{PRINTER_${I}_PORT:="910${I}"\} eval BAUD=\$\{PRINTER_${I}_SPEED:-"9600"\} eval SIZE=\$\{PRINTER_${I}_DATABITS:-"8"\} eval PARITY=\$\{PRINTER_${I}_PARITY:-"none"\} eval FLOW=\$\{PRINTER_${I}_FLOWCTRL:-"soft"\} JETPIPE_ARGS= [ -n "$BAUD" ] && JETPIPE_ARGS="${JETPIPE_ARGS} -b ${BAUD}" [ -n "$SIZE" ] && JETPIPE_ARGS="${JETPIPE_ARGS} -y ${SIZE}" [ -n "$PARITY" ] && JETPIPE_ARGS="${JETPIPE_ARGS} -p ${PARITY}" if [ -n "$FLOW" ]; then if [ "$FLOW" = "soft" ]; then JETPIPE_ARGS="${JETPIPE_ARGS} -x" else JETPIPE_ARGS="${JETPIPE_ARGS} -r" fi fi /usr/sbin/jetpipe ${JETPIPE_ARGS} ${PRINTER_DEVICE} ${PORT} fi done } start_sound() { if boolean_is_true "$SOUND" ; then case "$SOUND_DAEMON" in pulse|'') # The default when no value is set # Explicitly allow pulse user access to sound devices, ignore errors if [ -x /usr/bin/setfacl ]; then /usr/bin/setfacl -m u:pulse:rw /dev/snd/* > /dev/null 2>&1 fi # Requires 0.9.16+ which uses module-udev-detect instead of # module-detect and module-stream-restore instead of # module-volume-restore PULSE_DETECT=module-udev-detect PULSE_VOLUME_RESTORE=module-stream-restore /usr/bin/pulseaudio --system \ --exit-idle-time=-1 \ --disable-shm \ --no-cpu-limit \ --resample-method=trivial \ --high-priority \ --log-target=syslog \ -L $PULSE_DETECT \ -L "module-native-protocol-tcp auth-anonymous=1" \ -L $PULSE_VOLUME_RESTORE \ -L module-rescue-streams \ -L "module-native-protocol-unix auth-anonymous=1" \ -L module-suspend-on-idle \ -n & ;; [Ff][Aa][Ll][Ss][Ee]|[Nn]|[Nn][Oo]) # Do not do anything if SOUND_DAEMON is False, N, or No true ;; *) warn "Unable to start unsupported sound daemon: '$SOUND_DAEMON'" ;; esac fi } configure_sound_volume() { if boolean_is_true "${SOUND:-True}" ; then CARD_NUM=${1:-0} # Set up sound volume ## Set higher volume than default if not specified by lts.conf [ -z "$VOLUME" ] && VOLUME=90 [ -z "$PCM_VOLUME" ] && PCM_VOLUME=90 LANG=C amixer -c${CARD_NUM} scontents | while read line; do if [ -n "$(echo $line|grep 'Simple mixer control')" ]; then channel=$(echo $line|sed -e 's/^Simple mixer control //') else if [ -n "$channel" ]; then # Translate the channel name into an environmentally # friendly variable. In other words, a variable # in all caps, where forward slashes, hyphens, and # spaces are replaced by underscores, and anything # in parentheses is dropped completely # eg. if the channel is named 'Mic Boost (+20dB)' # then the variable is simply MIC_BOOST_SWITCH # # Oh, and SWITCH is used for on/off switches - value # should be on or off, and VOLUME is used for volumes # where the value should be a number representing a # percentage channel_name=$(echo ${channel}|sed -e s/^\'// -e s/\'.*$// -e 's/ -//g' -e 's/ [(].*[)]//' -e 's/\//_/g' -e 's/ /_/g' -e 's/-/_/g' | awk '{ print toupper($0) }') if [ -n "$(echo $line|grep volume)" ]; then eval channel_vol="\$${channel_name}_VOLUME" if [ "${channel_name}" = "MIC" ]; then cap="cap" else unset cap fi if boolean_is_true "${VOLUME_MANUAL}"; then [ -n "${channel_vol}" ] && echo sset "${channel}" ${channel_vol}% unmute $cap else # Set default MIC volumes to 40 if unspecified # This should resolve feedback issues case "${channel_name}" in *MIC*) [ -z "${channel_vol}" ] && channel_vol=40 ;; esac echo sset "${channel}" ${channel_vol:-$VOLUME}% unmute $cap fi fi if [ -n "$(echo $line|grep switch)" ]; then eval channel_switch="\$${channel_name}_SWITCH" [ -n "${channel_switch}" ] && echo sset "${channel}" ${channel_switch} fi fi unset channel fi done | amixer -c${CARD_NUM} --stdin >/dev/null 2>&1 fi } start_screen_sessions() { # If no default was found, there's no SCREEN_xx to be started, so exit test -n "$SCREEN_DEFAULT" || return # Start the default screen and make it the active tty openvt -f -c "${SCREEN_DEFAULT#0}" -s -- /usr/share/ltsp/screen_session "$SCREEN_DEFAULT" # Give the default screen a head start sleep 1 # Launch the other screens without switching to them for i in 01 02 03 04 05 06 07 08 09 10 11 12; do test "$i" -eq "$SCREEN_DEFAULT" && continue eval "screen=\$SCREEN_$i" if [ -n "$screen" ]; then openvt -f -c "${i#0}" -- /usr/share/ltsp/screen_session "$i" fi done }