Add --yes option to always answer yes

This commit is contained in:
2023-03-15 14:01:07 -04:00
parent fdf2fe8141
commit 3ca121d7f3
3 changed files with 35 additions and 11 deletions

View File

@@ -45,6 +45,8 @@ $ installJRMC --help
The webroot directory to install the repo (default: /var/www/jriver/) The webroot directory to install the repo (default: /var/www/jriver/)
--createrepo-user USER --createrepo-user USER
The web server user if different from the current user The web server user if different from the current user
--yes, -y
Always assume yes for questions
--version, -v --version, -v
Print this script version and exit Print this script version and exit
--debug, -d --debug, -d

View File

@@ -54,6 +54,8 @@ $ installJRMC --help
The webroot directory to install the repo (default: /var/www/jriver/) The webroot directory to install the repo (default: /var/www/jriver/)
--createrepo-user USER --createrepo-user USER
The web server user if different from the current user The web server user if different from the current user
--yes, -y
Always assumes yes for questions
--version, -v --version, -v
Print this script version and exit Print this script version and exit
--debug, -d --debug, -d
@@ -84,7 +86,7 @@ jriver-createrepo (system)
By default installs as root service to handle www permissions more gracefully By default installs as root service to handle www permissions more gracefully
[/code] [/code]
By default, MC services use a sane `--service-type` listed next to the service name in the Services description. User services can be manipulated as an unprivileged user, for example: *systemctl --user stop jriver-mediacenter* and begin at user login. System services are manipulable as root, for example: `sudo systemctl stop jriver-servicename@username.service` and begin at system boot. Note that it is possible to run all services of a particular user at boot using [url=https://www.freedesktop.org/software/systemd/man/loginctl.html]sudo loginctl enable-linger username[/url]. By default, MC services use a sane `--service-type` listed next to the service name in the Services description. User services can be manipulated as an unprivileged user, for example: [i]systemctl --user stop jriver-mediacenter[/i] and begin at user login. System services are manipulable as root, for example: [i]sudo systemctl stop jriver-servicename@username.service[/i] and begin at system boot. Note that it is possible to run all services of a particular user at boot using [url=https://www.freedesktop.org/software/systemd/man/loginctl.html]sudo loginctl enable-linger username[/url].
Multiple services (but not --service-types) can be installed at one time using multiple --service blocks: [code]installJRMC --install repo --service jriver-x11vnc --service jriver-mediacenter[/code] Multiple services (but not --service-types) can be installed at one time using multiple --service blocks: [code]installJRMC --install repo --service jriver-x11vnc --service jriver-mediacenter[/code]

View File

@@ -17,11 +17,11 @@
shopt -s extglob shopt -s extglob
declare -g SCRIPTVERSION="1.0-rc6" declare -g SCRIPTVERSION="1.0-dev"
declare -g OUTPUTDIR="$PWD/output" declare -g OUTPUTDIR="$PWD/output"
declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,76.0.html" # MC30 declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,76.0.html" # MC30
declare -g DEBIANBASE="buster" declare -g DEBIANBASE="buster"
declare -g MCVERSION_HARDCODE="${MCVERSION:-"30.0.67"}" # Hardcoded fallback declare -g MCVERSION_HARDCODE="${MCVERSION:-"30.0.72"}" # Hardcoded fallback
declare -g CREATEREPO_WEBROOT="/var/www/jriver" declare -g CREATEREPO_WEBROOT="/var/www/jriver"
declare -g USER="${SUDO_USER:-$USER}" declare -g USER="${SUDO_USER:-$USER}"
declare -g HOME; HOME=$(getent passwd "$USER" | cut -d: -f6) declare -g HOME; HOME=$(getent passwd "$USER" | cut -d: -f6)
@@ -45,7 +45,7 @@ printHelp() {
--compat --compat
Build/install MC locally without minimum dependency version requirements Build/install MC locally without minimum dependency version requirements
--mcversion VERSION --mcversion VERSION
Specify the MC version, ex. "30.0.67" (default: latest version) Specify the MC version, ex. "30.0.72" (default: latest version)
--arch VERSION --arch VERSION
Specify the MC architecture, ex. "amd64", "arm64", etc (default: host architecture) Specify the MC architecture, ex. "amd64", "arm64", etc (default: host architecture)
--outputdir PATH --outputdir PATH
@@ -68,14 +68,16 @@ printHelp() {
Specify the webroot directory to install the repo (default: /var/www/jriver) Specify the webroot directory to install the repo (default: /var/www/jriver)
--createrepo-user USER --createrepo-user USER
Specify the web server user if it differs from $USER Specify the web server user if it differs from $USER
--uninstall, -u
Uninstall JRiver MC, remove services, containers, and firewall rules (does not remove library files)
--yes, -y
Always assume yes for questions
--version, -v --version, -v
Print this script version and exit Print this script version and exit
--debug, -d --debug, -d
Print debug output Print debug output
--help, -h --help, -h
Print help dialog and exit Print help dialog and exit
--uninstall, -u
Uninstall JRiver MC, remove services, containers, and firewall rules (does not remove library files)
SERVICES SERVICES
jriver-mediaserver (default --service-type=user) jriver-mediaserver (default --service-type=user)
@@ -108,6 +110,7 @@ debug() { (( DEBUG )) && echo "Debug: $*"; }
err() { echo "Error: $*" >&2; } err() { echo "Error: $*" >&2; }
askOk() { askOk() {
declare response declare response
(( YES_SWITCH )) && return 0
read -r -p "$* [y/N]: " response read -r -p "$* [y/N]: " response
[[ "${response,,}" =~ ^(yes|y)$ ]] [[ "${response,,}" =~ ^(yes|y)$ ]]
} }
@@ -127,7 +130,7 @@ parseInput() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH TEST_SWITCH declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH TEST_SWITCH
declare -g LOCAL_INSTALL_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH declare -g LOCAL_INSTALL_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH YES_SWITCH
declare -g USER_VERSION_SWITCH USER_ARCH declare -g USER_VERSION_SWITCH USER_ARCH
declare -g OUTPUTDIR RESTOREFILE BETAPASS SERVICE_TYPE declare -g OUTPUTDIR RESTOREFILE BETAPASS SERVICE_TYPE
declare -g VNCPASS USER_DISPLAY CREATEREPO_WEBROOT declare -g VNCPASS USER_DISPLAY CREATEREPO_WEBROOT
@@ -148,7 +151,7 @@ parseInput() {
long_opts="install:,build::,outputdir:,mcversion:,restorefile:,betapass:," long_opts="install:,build::,outputdir:,mcversion:,restorefile:,betapass:,"
long_opts+="service-type:,service:,services:,version,debug,help,uninstall," long_opts+="service-type:,service:,services:,version,debug,help,uninstall,"
long_opts+="createrepo::,createrepo-webroot:,createrepo-user:," long_opts+="createrepo::,createrepo-webroot:,createrepo-user:,"
long_opts+="vncpass:,display:,container:,tests,compat,arch:" long_opts+="vncpass:,display:,container:,tests,compat,arch:,yes"
short_opts="+i:vb::dhus:c:" short_opts="+i:vb::dhus:c:"
# Redeclare DEBUG and catch permanently with getopt # Redeclare DEBUG and catch permanently with getopt
@@ -221,6 +224,9 @@ parseInput() {
--container|-c) --container|-c)
shift && CONTAINERS+=("$1") shift && CONTAINERS+=("$1")
;; ;;
--yes|-y)
YES_SWITCH=1
;;
--version|-v) --version|-v)
echo "Version: $SCRIPTVERSION" echo "Version: $SCRIPTVERSION"
exit 0 exit 0
@@ -323,6 +329,8 @@ init() {
ID="arch" ID="arch"
else else
err "OS detection failed!" err "OS detection failed!"
askOk ""
ID="unknown"
exit 1 exit 1
fi fi
esac esac
@@ -359,6 +367,8 @@ init() {
PKG_QUERY(){ sudo pacman -Qs "$@"; } PKG_QUERY(){ sudo pacman -Qs "$@"; }
PKG_INSTALL_LOCAL(){ installMCARCH; } PKG_INSTALL_LOCAL(){ installMCARCH; }
;; ;;
unknown)
PKG_INSTALL_LOCAL(){ installMCRAW; }
esac esac
} }
@@ -790,7 +800,7 @@ buildRPM() {
####################################### #######################################
# Installs local Media Center DEB package and optional compatability fixes # Installs Media Center DEB package and optional compatability fixes
####################################### #######################################
installMCDEB() { installMCDEB() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
@@ -821,7 +831,7 @@ installMCDEB() {
####################################### #######################################
# Installs local Media Center RPM package # Installs Media Center RPM package
####################################### #######################################
installMCRPM() { installMCRPM() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
@@ -833,6 +843,16 @@ installMCRPM() {
} }
#######################################
# Installs Media Center manually
#######################################
installMCRAW() {
debug "Running: ${FUNCNAME[0]}"
}
####################################### #######################################
# Installs mesa-va-drivers-freeworld # Installs mesa-va-drivers-freeworld
####################################### #######################################
@@ -1324,7 +1344,7 @@ service_jriver-x11vnc() {
# If .Xauthority file is missing, generate a dummy for x11vnc -auth guess # If .Xauthority file is missing, generate a dummy for x11vnc -auth guess
if [[ ! -f "$HOME/.Xauthority" ]]; then if [[ ! -f "$HOME/.Xauthority" ]]; then
[[ "$XDG_SESSION_TYPE" == "wayland" ]] && [[ "$XDG_SESSION_TYPE" == "wayland" ]] &&
ask_ok "Unsupported Wayland session detected for x11vnc, continue?" || return 1 askOk "Unsupported Wayland session detected for x11vnc, continue?" || return 1
touch "$HOME/.Xauthority" touch "$HOME/.Xauthority"
xauth generate "$DISPLAY" . trusted xauth generate "$DISPLAY" . trusted
xauth add "$HOST$DISPLAY" . "$(xxd -l 16 -p /dev/urandom)" xauth add "$HOST$DISPLAY" . "$(xxd -l 16 -p /dev/urandom)"