#!/bin/sh ############################################################################### # BRLTTY - A background process providing access to the console screen (when in # text mode) for a blind person using a refreshable braille display. # # Copyright (C) 1995-2021 by The BRLTTY Developers. # # BRLTTY comes with ABSOLUTELY NO WARRANTY. # # This is free software, placed under the terms of the # GNU Lesser General Public License, as published by the Free Software # Foundation; either version 2.1 of the License, or (at your option) any # later version. Please see the file LICENSE-LGPL for details. # # Web Page: http://brltty.app/ # # This software is maintained by Dave Mielke . ############################################################################### set -e . "`dirname "${0}"`/brltty-prologue.sh" . "${programDirectory}/brltty-config.sh" declare -A privilegeParameters parseParameterString privilegeParameters "${BRLTTY_PRIVILEGE_PARAMETERS}" lx readonly defaultUserName="${privilegeParameters["USER"]}" readonly defaultUserInformation="Braille Device Daemon" readonly defaultHomeDirectory="${BRLTTY_UPDATABLE_DIRECTORY}" readonly defaultLoginShell="/sbin/nologin" showProgramUsageNotes() { cat </dev/null 2>&1 then "${allowChanges}" || semanticError "user already exists: ${userName} - use -E (existing) to allow" command=(usermod) else "${allowCreate}" || semanticError "user doesn't exist: ${userName} - use -N (new) to allow" command=(useradd --system) [ -n "${primaryGroup}" ] || command+=(--user-group) [ -n "${userInformation}" ] || userInformation="${defaultUserInformation}" [ -n "${homeDirectory}" ] || homeDirectory="${defaultHomeDirectory}" [ -n "${loginShell}" ] || loginShell="${defaultLoginShell}" if [ -n "${homeDirectory}" ] then command+=(--create-home) else command+=(--no-create-home) fi fi [ -n "${homeDirectory}" ] && command+=(--home "${homeDirectory}") [ -n "${primaryGroup}" ] && command+=(--gid "${primaryGroup}") [ -n "${userInformation}" ] && command+=(--comment "${userInformation}") [ -n "${loginShell}" ] && command+=(--shell "${loginShell}") "${noGroups}" || { "${noALSA}" || addGroups audio "${noBrlapi}" || addGroups "${BRLAPI_KEY_FILE}" "${noConsoles}" || addGroups tty /dev/vcs1 /dev/tty1 "${noKeyboards}" || addGroups input "${noPulse}" || addGroups pulse-access "${noSerial}" || addGroups /dev/ttyS0 "${noUSB}" || addGroups /dev/bus/usb groupsOperand="${groupList[*]}" groupsOperand="${groupsOperand// /,}" command+=(--groups "${groupsOperand}") } "${testMode}" || { if "${useSudo}" then sudo -v elif [ "$(id -u)" -ne 0 ] then semanticError "not executing as root" fi } command+=(-- "${userName}") executeCommand "${command[@]}" exit 0