Compare commits
2 Commits
c503fd994e
...
4e0f3cfc8f
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e0f3cfc8f | |||
| 207d09e689 |
@@ -22,9 +22,9 @@ You can always find the latest supported options by running `installJRMC --help`
|
||||
repo: Install MC from repository, future updates will be handled by the system package manager
|
||||
rpm: Build and install MC locally (RPM-based OSes only)
|
||||
deb: Download and install official MC package locally (useful with --compat flag for older distros)
|
||||
--build=[opensuse|fedora|centos]
|
||||
--build=[suse|fedora|centos]
|
||||
Build RPM from source DEB but do not install
|
||||
Specify cross-build target with optional argument, note '=' (ex. --build=opensuse)
|
||||
Specify cross-build target with optional argument, note '=' (ex. --build=suse)
|
||||
--compat
|
||||
Build/install MC without minimum library specifiers
|
||||
--mcversion VERSION
|
||||
|
||||
122
installJRMC
122
installJRMC
@@ -38,9 +38,9 @@ printHelp() {
|
||||
repo: Install MC from repository, updates are handled by the system package manager
|
||||
rpm: Build and install RPM locally (RPM-based distros only)
|
||||
deb: Download and install offcial MC package locally (useful with --compat flag for older distros)
|
||||
--build=[opensuse|fedora|centos]
|
||||
--build=[suse|fedora|centos]
|
||||
Build RPM from source DEB but do not install
|
||||
Specify cross-build target with optional argument, note '=' (ex. --build=opensuse)
|
||||
Specify cross-build target with optional argument, note '=' (ex. --build=suse)
|
||||
--compat
|
||||
Build/install MC without minimum library specifiers
|
||||
--mcversion VERSION
|
||||
@@ -105,9 +105,18 @@ askOk() {
|
||||
declare response
|
||||
read -r -p "$* [y/N]: " response
|
||||
[[ "${response,,}" =~ ^(yes|y)$ ]]
|
||||
return $?
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
#######################################
|
||||
# Parse /etc/os-release and provide a compatability layer for unrecognzied distros
|
||||
#######################################
|
||||
getOS() {
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
declare -g ID
|
||||
|
||||
if [[ -e "/etc/os-release" ]]; then
|
||||
source "/etc/os-release"
|
||||
else
|
||||
@@ -115,24 +124,55 @@ getOS() {
|
||||
err "Your OS is unsupported"
|
||||
printHelp && exit 1
|
||||
fi
|
||||
|
||||
debug "Platform: $ID $VERSION_ID"
|
||||
|
||||
case "$ID" in
|
||||
centos|fedora|debian|ubuntu)
|
||||
return 0
|
||||
;;
|
||||
linuxmint|neon)
|
||||
ID="ubuntu"
|
||||
;;
|
||||
*suse*)
|
||||
ID="suse"
|
||||
;;
|
||||
*)
|
||||
echo "Attempting to autodetect RPM/DEB distro, this may be unreliable"
|
||||
if hash dnf &>/dev/null || hash yum &>/dev/null; then
|
||||
ID="fedora"
|
||||
elif hash apt &>/dev/null; then
|
||||
ID="ubuntu"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
debug "Using compatability platform: $ID"
|
||||
}
|
||||
|
||||
|
||||
parseInput() {
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
declare -g TARGET=${TARGET:-$ID}
|
||||
declare -g CREATEREPO_USER="${CREATEREPO_USER:$USER}"
|
||||
declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH
|
||||
declare -g CREATEREPO_SWITCH UNINSTALL_SWITCH DEB_INSTALL_SWITCH
|
||||
declare -g TARGET OUTPUTDIR MCVERSION RESTOREFILE BETAPASS SERVICE_TYPE
|
||||
declare -g VNCPASS USER_DISPLAY CREATEREPO_WEBROOT CREATEREPO_USER
|
||||
declare -g OUTPUTDIR MCVERSION RESTOREFILE BETAPASS SERVICE_TYPE
|
||||
declare -g VNCPASS USER_DISPLAY CREATEREPO_WEBROOT
|
||||
declare -ga SERVICES CONTAINERS
|
||||
declare long_opts short_opts
|
||||
|
||||
if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
|
||||
REPO_INSTALL_SWITCH=1
|
||||
elif [[ $# -eq 1 && "$1" =~ ^(--compat)$ ]]; then
|
||||
TARGET="$ID"
|
||||
BUILD_SWITCH=1
|
||||
# separate ordering is probably more reliable
|
||||
if [[ "$ID" =~ (ubuntu|debian) ]]; then
|
||||
DEB_INSTALL_SWITCH=1
|
||||
elif [[ "$ID" =~ (fedora|centos|suse) ]]; then
|
||||
RPM_INSTALL_SWITCH=1
|
||||
fi
|
||||
fi
|
||||
|
||||
long_opts="install:,build::,outputdir:,mcversion:,restorefile:,betapass:,"
|
||||
@@ -296,12 +336,12 @@ installPackage() {
|
||||
skip_check_installed=1
|
||||
;;
|
||||
--allow-downgrades)
|
||||
[[ "$ID" =~ (debian|ubuntu|linuxmint|neon) ]] && install_flags+=(--allow-downgrades)
|
||||
[[ "$ID" =~ (debian|ubuntu) ]] && install_flags+=(--allow-downgrades)
|
||||
;;
|
||||
--nogpgcheck)
|
||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||
install_flags+=(--nogpgcheck)
|
||||
elif [[ "$ID" =~ ^opensuse.* ]]; then
|
||||
elif [[ "$ID" == "suse" ]]; then
|
||||
install_flags+=(--allow-unsigned-rpm)
|
||||
fi
|
||||
;;
|
||||
@@ -321,7 +361,7 @@ installPackage() {
|
||||
fi
|
||||
|
||||
# Aliases
|
||||
if [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
|
||||
if [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
|
||||
declare -A PKG_ALIASES
|
||||
PKG_ALIASES["xorg-x11-utils"]="xorg-x11"
|
||||
PKG_ALIASES["rpm-build"]="rpm"
|
||||
@@ -372,7 +412,7 @@ installMCDEB() {
|
||||
if (( COMPAT_SWITCH )); then
|
||||
declare extract_dir && extract_dir="$(mktemp -d)"
|
||||
mcdeb="${MCDEB/.deb/.compat.deb}"
|
||||
pushd "$extract_dir" &>/dev/null || return $?
|
||||
pushd "$extract_dir" &>/dev/null || return
|
||||
ar x "$MCDEB"
|
||||
tar -xJf "control.tar.xz"
|
||||
# Remove minimum version specifiers from control file
|
||||
@@ -380,7 +420,7 @@ installMCDEB() {
|
||||
sed -i 's/([^)]*)//g' "control" # TODO MC DEB package error
|
||||
tar -cJf "control.tar.xz" "control" "postinst"
|
||||
ar rcs "$mcdeb" "debian-binary" "control.tar.xz" "data.tar.xz"
|
||||
popd &>/dev/null || return $?
|
||||
popd &>/dev/null || return
|
||||
rm -rf "$extract_dir"
|
||||
pkg_install_cmd+=" --allow-downgrades"
|
||||
fi
|
||||
@@ -405,7 +445,7 @@ addRepo() {
|
||||
baseurl=https://repos.bryanroessler.com/jriver
|
||||
gpgcheck=0
|
||||
EOF"
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
|
||||
installPackage wget
|
||||
declare sources_dir="/etc/apt/sources.list.d"
|
||||
[[ ! -d $sources_dir ]] && sudo mkdir -p "$sources_dir"
|
||||
@@ -414,7 +454,7 @@ addRepo() {
|
||||
deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main
|
||||
EOF"
|
||||
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | sudo apt-key add - &>/dev/null
|
||||
elif [[ "$ID" =~ ^opensuse.* ]]; then
|
||||
elif [[ "$ID" == "suse" ]]; then
|
||||
sudo zypper addrepo --no-gpgcheck "https://repos.bryanroessler.com/jriver" jriver &>/dev/null
|
||||
fi
|
||||
}
|
||||
@@ -493,7 +533,7 @@ acquireDeb() {
|
||||
buildRPM() {
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
declare id i rpmbuild_cmd
|
||||
declare i rpmbuild_cmd
|
||||
declare -a requires recommends
|
||||
declare -A dupes
|
||||
|
||||
@@ -504,11 +544,9 @@ buildRPM() {
|
||||
fi
|
||||
|
||||
[[ ! -d "$OUTPUTDIR/SPECS" ]] && mkdir -p "$OUTPUTDIR/SPECS"
|
||||
|
||||
# Use --target parameter override
|
||||
id="${TARGET:-$ID}"
|
||||
if [[ ! "$id" =~ (fedora|centos|opensuse.*) ]]; then
|
||||
err "The current RPM build target $id is not supported, manually specify with --target"
|
||||
|
||||
if [[ ! "$TARGET" =~ (fedora|centos|suse) ]]; then
|
||||
err "The current RPM build target $TARGET is not supported, manually specify with --target"
|
||||
err "The DEB file is located at $MCDEB"
|
||||
return 1
|
||||
fi
|
||||
@@ -532,7 +570,7 @@ buildRPM() {
|
||||
recommends=("${recommends[@]//)/}")
|
||||
|
||||
# Translate package names
|
||||
case "$id" in
|
||||
case "$TARGET" in
|
||||
fedora|centos)
|
||||
requires=("${requires[@]/libc6/glibc}")
|
||||
requires=("${requires[@]/libasound2/alsa-lib}")
|
||||
@@ -562,7 +600,7 @@ buildRPM() {
|
||||
requires=("${requires[@]/libvulkan1/vulkan-loader}")
|
||||
requires=("${requires[@]/libepoxy0/libepoxy}")
|
||||
;;
|
||||
opensuse*)
|
||||
suse)
|
||||
requires=("${requires[@]/libc6/glibc}")
|
||||
requires=("${requires[@]/libasound2/alsa-lib}")
|
||||
requires=("${requires[@]/libx11-6/libX11-6}")
|
||||
@@ -678,22 +716,21 @@ runCreaterepo() {
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
declare cr_cmd cr_cp_cmd cr_mkdir_cmd cr_chown_cmd
|
||||
declare cr_user="${CREATEREPO_USER:$USER}"
|
||||
|
||||
installPackage createrepo_c
|
||||
|
||||
# If the webroot does not exist, create it
|
||||
if [[ ! -d "$CREATEREPO_WEBROOT" ]]; then
|
||||
cr_mkdir_cmd="sudo -u $cr_user mkdir -p $CREATEREPO_WEBROOT"
|
||||
cr_mkdir_cmd="sudo -u $CREATEREPO_USER mkdir -p $CREATEREPO_WEBROOT"
|
||||
debug "$cr_mkdir_cmd" || cr_mkdir_cmd+=" &>/dev/null"
|
||||
if ! eval "$cr_mkdir_cmd"; then
|
||||
cr_mkdir_cmd="sudo mkdir -p $CREATEREPO_WEBROOT"
|
||||
debug "$cr_mkdir_cmd" || cr_mkdir_cmd+=" &>/dev/null"
|
||||
cr_chown_cmd="sudo chown -R $cr_user:$cr_user $CREATEREPO_WEBROOT"
|
||||
cr_chown_cmd="sudo chown -R $CREATEREPO_USER:$CREATEREPO_USER $CREATEREPO_WEBROOT"
|
||||
debug "$cr_chown_cmd" || cr_chown_cmd+=" &>/dev/null"
|
||||
if ! ( eval "$cr_mkdir_cmd" && eval "$cr_chown_cmd" ); then
|
||||
err "Could not create the createrepo-webroot path!"
|
||||
err "Make sure that the webroot $CREATEREPO_WEBROOT is writeable by user $cr_user"
|
||||
err "Make sure that the webroot $CREATEREPO_WEBROOT is writeable by user $CREATEREPO_USER"
|
||||
err "Or change the repo ownership with --createrepo-user"
|
||||
return 1
|
||||
fi
|
||||
@@ -702,7 +739,7 @@ runCreaterepo() {
|
||||
|
||||
# Copy built rpms to webroot
|
||||
cr_cp_cmd="sudo cp -nf $MCRPM $CREATEREPO_WEBROOT"
|
||||
cr_chown_cmd="sudo chown -R $cr_user:$cr_user $CREATEREPO_WEBROOT"
|
||||
cr_chown_cmd="sudo chown -R $CREATEREPO_USER:$CREATEREPO_USER $CREATEREPO_WEBROOT"
|
||||
debug "$cr_cp_cmd" || cr_cp_cmd+=" &>/dev/null"
|
||||
debug "$cr_chown_cmd" || cr_cp_cmd+=" &>/dev/null"
|
||||
if ! ( eval "$cr_cp_cmd" && eval "$cr_chown_cmd" ); then
|
||||
@@ -711,13 +748,13 @@ runCreaterepo() {
|
||||
fi
|
||||
|
||||
# Run createrepo
|
||||
cr_cmd="sudo -u $cr_user createrepo -q $CREATEREPO_WEBROOT"
|
||||
cr_cmd="sudo -u $CREATEREPO_USER createrepo -q $CREATEREPO_WEBROOT"
|
||||
[[ -d "$CREATEREPO_WEBROOT/repodata" ]] && cr_cmd+=" --update"
|
||||
debug "$cr_cmd" || cr_cmd+=" &>/dev/null"
|
||||
if ! eval "$cr_cmd"; then
|
||||
cr_cmd="sudo createrepo -q $CREATEREPO_WEBROOT"
|
||||
[[ -d "$CREATEREPO_WEBROOT/repodata" ]] && cr_cmd+=" --update"
|
||||
cr_chown_cmd="sudo chown -R $cr_user:$cr_user $CREATEREPO_WEBROOT"
|
||||
cr_chown_cmd="sudo chown -R $CREATEREPO_USER:$CREATEREPO_USER $CREATEREPO_WEBROOT"
|
||||
debug "$cr_cmd" || cr_cmd+=" &>/dev/null"
|
||||
debug "$cr_chown_cmd" || cr_cp_cmd+=" &>/dev/null"
|
||||
if ! ( eval "$cr_cmd" && eval "$cr_chown_cmd"); then
|
||||
@@ -794,7 +831,7 @@ openFirewall() {
|
||||
fi
|
||||
|
||||
# Open the ports
|
||||
if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then
|
||||
if [[ "$ID" =~ ^(fedora|centos|suse)$ ]]; then
|
||||
installPackage firewalld
|
||||
if ! firewall_cmd --get-services | grep -q "$1"; then
|
||||
firewall_cmd --permanent --new-service="$1" &>/dev/null
|
||||
@@ -806,7 +843,7 @@ openFirewall() {
|
||||
firewall_cmd --add-service "$1" --permanent &>/dev/null
|
||||
firewall_cmd --reload &>/dev/null
|
||||
fi
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
|
||||
# Debian ufw package state is broken on fresh installations
|
||||
installPackage ufw
|
||||
if [[ ! -f "/etc/ufw/applications.d/$1" ]]; then
|
||||
@@ -1116,10 +1153,7 @@ service_jriver-x11vnc() {
|
||||
service_jriver-createrepo() {
|
||||
debug "Running: ${FUNCNAME[0]}"
|
||||
|
||||
declare id="${TARGET:-$ID}"
|
||||
declare cr_user="${CREATEREPO_USER:$USER}"
|
||||
|
||||
if [[ "$USER" != "$cr_user" ]]; then
|
||||
if [[ "$USER" != "$CREATEREPO_USER" ]]; then
|
||||
USER="root" SERVICE_TYPE="system" setServiceVars "${FUNCNAME[0]##*_}"
|
||||
else
|
||||
setServiceVars "${FUNCNAME[0]##*_}"
|
||||
@@ -1131,7 +1165,7 @@ service_jriver-createrepo() {
|
||||
|
||||
[Service]
|
||||
$USER_STRING
|
||||
ExecStart=$PWD/installJRMC --target $id --outputdir $OUTPUTDIR --createrepo --createrepo-webroot $CREATEREPO_WEBROOT --createrepo-user $cr_user
|
||||
ExecStart=$PWD/installJRMC --target $TARGET --outputdir $OUTPUTDIR --createrepo --createrepo-webroot $CREATEREPO_WEBROOT --createrepo-user $CREATEREPO_USER
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1352,7 +1386,7 @@ uninstall() {
|
||||
sudo rm -rf \
|
||||
"/etc/yum.repos.d/jriver.repo" \
|
||||
/etc/apt/sources.list.d/{jriver,mediacenter}*.list # also remove legacy repo files
|
||||
if [[ "$ID" =~ ^opensuse.* ]]; then
|
||||
if [[ "$ID" == "suse" ]]; then
|
||||
sudo zypper rr jriver &>/dev/null
|
||||
fi
|
||||
|
||||
@@ -1406,7 +1440,7 @@ main() {
|
||||
getOS
|
||||
|
||||
# Some distros need external repos installed for MC libraries
|
||||
if [[ "$ID" =~ (ubuntu|linuxmint|neon) ]]; then
|
||||
if [[ "$ID" =~ (ubuntu) ]]; then
|
||||
echo "Adding universe repository"
|
||||
if ! grep ^deb /etc/apt/sources.list|grep -q universe; then
|
||||
sudo add-apt-repository universe
|
||||
@@ -1423,13 +1457,13 @@ main() {
|
||||
pkg_update(){ sudo dnf makecache; }
|
||||
pkg_query(){ rpm -q "$@"; }
|
||||
firewall_cmd(){ sudo firewall-cmd "$@"; }
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
|
||||
pkg_install(){ sudo apt-get install -y -q0 "$@"; }
|
||||
pkg_remove(){ sudo apt-get remove --auto-remove -y -q0 "$@"; }
|
||||
pkg_update(){ sudo apt-get update -y -q0; }
|
||||
pkg_query(){ dpkg -s "$@"; }
|
||||
firewall_cmd(){ sudo ufw "$@"; }
|
||||
elif [[ "$ID" =~ ^opensuse.* ]]; then
|
||||
elif [[ "$ID" == "suse" ]]; then
|
||||
pkg_install(){ sudo zypper --non-interactive -q install --force --no-confirm "$@"; }
|
||||
pkg_remove(){ sudo zypper --non-interactive -q remove --clean-deps "$@"; }
|
||||
pkg_update(){ sudo zypper --non-interactive -q refresh jriver; }
|
||||
@@ -1453,10 +1487,10 @@ main() {
|
||||
MVERSION="${MCVERSION%%.*}"
|
||||
|
||||
# Set target package name
|
||||
if [[ "$ID" =~ ^(fedora|centos|opensuse.*)$ ]]; then
|
||||
if [[ "$ID" =~ ^(fedora|centos|suse)$ ]]; then
|
||||
MCPKG="MediaCenter"
|
||||
[[ "$VERSION_SOURCE" == "user input" ]] && MCPKG="$MCPKG-$MCVERSION"
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
|
||||
elif [[ "$ID" =~ ^(debian|ubuntu)$ ]]; then
|
||||
MCPKG="mediacenter$MVERSION"
|
||||
[[ "$VERSION_SOURCE" == "user input" ]] && MCPKG="$MCPKG=$MCVERSION"
|
||||
fi
|
||||
@@ -1469,7 +1503,7 @@ main() {
|
||||
fi
|
||||
|
||||
if (( REPO_INSTALL_SWITCH )); then
|
||||
if [[ "$ID" =~ ^opensuse.*$ ]]; then
|
||||
if [[ "$ID" == "suse" ]]; then
|
||||
echo "A SUSE repository is not yet available"
|
||||
echo "Use --install rpm to build and install a SUSE RPM instead"
|
||||
exit 1
|
||||
@@ -1487,9 +1521,7 @@ main() {
|
||||
if (( BUILD_SWITCH )); then
|
||||
installPackage "wget" "dpkg" "rpm-build"
|
||||
acquireDeb
|
||||
if [[ "$TARGET" =~ ^(fedora|centos|opensuse.*) ]]; then
|
||||
buildRPM
|
||||
fi
|
||||
buildRPM
|
||||
fi
|
||||
|
||||
if (( DEB_INSTALL_SWITCH )); then
|
||||
|
||||
Reference in New Issue
Block a user