Compare commits
20 Commits
5e1958b572
...
d61bdd4842
| Author | SHA1 | Date | |
|---|---|---|---|
| d61bdd4842 | |||
| 717a3f9f7f | |||
| 09a129e92c | |||
| 45697c0d9f | |||
| 1817c3ca79 | |||
| 559a9eebae | |||
| 72cdf25677 | |||
| 1f939dd773 | |||
| 46f92b7812 | |||
| 22c2be25bc | |||
| 5f030454b9 | |||
| 41d84497f0 | |||
| e85692e3fe | |||
| fe0e467e9f | |||
| 0c0dbbe5f4 | |||
| a4c9eb59c5 | |||
| 7de3192603 | |||
| aeca1c6547 | |||
| 00b286acb3 | |||
| 0e7ef57142 |
@@ -22,12 +22,11 @@ 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
|
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)
|
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)
|
deb: Download and install official MC package locally (useful with --compat flag for older distros)
|
||||||
--build
|
--build=[opensuse|fedora|centos]
|
||||||
Build RPM from source DEB but do not install
|
Build RPM from source DEB but do not install
|
||||||
--target opensuse|fedora|centos
|
Specify cross-build target with optional argument, note '=' (ex. --build=opensuse)
|
||||||
Crossbuild RPM for target distro
|
|
||||||
--compat
|
--compat
|
||||||
Build/install RPM without minimum library specifiers
|
Build/install MC without minimum library specifiers
|
||||||
--mcversion VERSION
|
--mcversion VERSION
|
||||||
Build or install a specific MC version, ex. "28.0.25"
|
Build or install a specific MC version, ex. "28.0.25"
|
||||||
--outputdir PATH
|
--outputdir PATH
|
||||||
|
|||||||
248
installJRMC
248
installJRMC
@@ -24,9 +24,6 @@ declare -g OUTPUTDIR="$PWD/output"
|
|||||||
declare -g CREATEREPO_WEBROOT="/var/www/jriver"
|
declare -g CREATEREPO_WEBROOT="/var/www/jriver"
|
||||||
declare -g USER; USER="${USER:-$(id -un)}"
|
declare -g USER; USER="${USER:-$(id -un)}"
|
||||||
|
|
||||||
# MC version
|
|
||||||
# MCVERSION="28.0.87" # to set manually, if unset use automatic latest check
|
|
||||||
|
|
||||||
printHelp() {
|
printHelp() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
@@ -41,10 +38,11 @@ printHelp() {
|
|||||||
repo: Install MC from repository, updates are handled by the system package manager
|
repo: Install MC from repository, updates are handled by the system package manager
|
||||||
rpm: Build and install RPM locally (RPM-based distros only)
|
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)
|
deb: Download and install offcial MC package locally (useful with --compat flag for older distros)
|
||||||
--build
|
--build=[opensuse|fedora|centos]
|
||||||
Build RPM from source DEB but do not install. Optional TARGET parameter enables RPM crossbuilding (ex. 'opensuse', 'fedora', 'centos')
|
Build RPM from source DEB but do not install
|
||||||
--target opensuse|fedora|centos
|
Specify cross-build target with optional argument, note '=' (ex. --build=opensuse)
|
||||||
Cross-build RPM or createrepo for target distro
|
--compat
|
||||||
|
Build/install MC without minimum library specifiers
|
||||||
--mcversion VERSION
|
--mcversion VERSION
|
||||||
Specify the MC version, ex. "28.0.94" (Default: latest)
|
Specify the MC version, ex. "28.0.94" (Default: latest)
|
||||||
--outputdir PATH
|
--outputdir PATH
|
||||||
@@ -65,8 +63,6 @@ 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
|
||||||
--compat
|
|
||||||
Build/install RPM without minimum library specifiers
|
|
||||||
--version, -v
|
--version, -v
|
||||||
Print this script version and exit
|
Print this script version and exit
|
||||||
--debug, -d
|
--debug, -d
|
||||||
@@ -126,16 +122,25 @@ getOS() {
|
|||||||
parseInput() {
|
parseInput() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
declare -g RPM_BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH DEB_INSTALL_SWITCH
|
declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH
|
||||||
declare -g TARGET OUTPUTDIR MCVERSION RESTOREFILE BETAPASS SERVICE_TYPE VNCPASS USER_DISPLAY CREATEREPO_WEBROOT CREATEREPO_USER
|
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 -ga SERVICES CONTAINERS
|
declare -ga SERVICES CONTAINERS
|
||||||
|
declare long_opts short_opts
|
||||||
|
|
||||||
if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
|
if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
|
||||||
echo "No options passed, defaulting to repo installation method"
|
|
||||||
REPO_INSTALL_SWITCH=1
|
REPO_INSTALL_SWITCH=1
|
||||||
|
elif [[ $# -eq 1 && "$1" =~ ^(--compat)$ ]]; then
|
||||||
|
TARGET="$ID"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if _input=$(getopt -o +i:vdhus:c: -l install:,build,target:,outputdir:,mcversion:,restorefile:,betapass:,service-type:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container:,tests,compat -- "$@"); then
|
long_opts="install:,build::,outputdir:,mcversion:,restorefile:,betapass:,"
|
||||||
|
long_opts+="service-type:,service:,version,debug,help,uninstall,createrepo,"
|
||||||
|
long_opts+="createrepo-webroot:,createrepo-user:,vncpass:,display:,container:,tests,compat"
|
||||||
|
short_opts="+i:vb::dhus:c:"
|
||||||
|
|
||||||
|
if _input=$(getopt -o $short_opts -l $long_opts -- "$@"); then
|
||||||
eval set -- "$_input"
|
eval set -- "$_input"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -143,10 +148,11 @@ parseInput() {
|
|||||||
shift
|
shift
|
||||||
case "$1" in
|
case "$1" in
|
||||||
rpm)
|
rpm)
|
||||||
RPM_BUILD_SWITCH=1
|
BUILD_SWITCH=1
|
||||||
RPM_INSTALL_SWITCH=1
|
RPM_INSTALL_SWITCH=1
|
||||||
;;
|
;;
|
||||||
deb)
|
deb)
|
||||||
|
BUILD_SWITCH=1
|
||||||
DEB_INSTALL_SWITCH=1
|
DEB_INSTALL_SWITCH=1
|
||||||
;;
|
;;
|
||||||
repo)
|
repo)
|
||||||
@@ -154,10 +160,8 @@ parseInput() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
--build)
|
--build|-b)
|
||||||
RPM_BUILD_SWITCH=1
|
BUILD_SWITCH=1
|
||||||
;;
|
|
||||||
--target)
|
|
||||||
shift && TARGET="$1"
|
shift && TARGET="$1"
|
||||||
;;
|
;;
|
||||||
--outputdir)
|
--outputdir)
|
||||||
@@ -179,7 +183,7 @@ parseInput() {
|
|||||||
shift && SERVICES+=("$1")
|
shift && SERVICES+=("$1")
|
||||||
;;
|
;;
|
||||||
--createrepo)
|
--createrepo)
|
||||||
RPM_BUILD_SWITCH=1
|
BUILD_SWITCH=1
|
||||||
CREATEREPO_SWITCH=1
|
CREATEREPO_SWITCH=1
|
||||||
;;
|
;;
|
||||||
--createrepo-webroot)
|
--createrepo-webroot)
|
||||||
@@ -230,6 +234,8 @@ parseInput() {
|
|||||||
err "Incorrect options provided"
|
err "Incorrect options provided"
|
||||||
printHelp && exit 1
|
printHelp && exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
! debug && echo "Use --debug for verbose output"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -273,6 +279,7 @@ getLatestVersion() {
|
|||||||
# Options:
|
# Options:
|
||||||
# --skip-check-installed: Do not check if package is already installed
|
# --skip-check-installed: Do not check if package is already installed
|
||||||
# --nogpgcheck: Disable GPG checks for RPM based distros
|
# --nogpgcheck: Disable GPG checks for RPM based distros
|
||||||
|
# --allow-downgrades: Useful for installing compatability versions on DEB based distros
|
||||||
# --silent, -s: Do not report errors (useful if package is not strictly required and errors are noisy)
|
# --silent, -s: Do not report errors (useful if package is not strictly required and errors are noisy)
|
||||||
#######################################
|
#######################################
|
||||||
installPackage() {
|
installPackage() {
|
||||||
@@ -281,13 +288,16 @@ installPackage() {
|
|||||||
declare -a pkg_array install_flags
|
declare -a pkg_array install_flags
|
||||||
declare pkg skip_check_installed silent _return pkg_install_cmd
|
declare pkg skip_check_installed silent _return pkg_install_cmd
|
||||||
|
|
||||||
if _input=$(getopt -o +s -l skip-check-installed,nogpgcheck,silent -- "$@"); then
|
if _input=$(getopt -o +s -l skip-check-installed,allow-downgrades,nogpgcheck,silent -- "$@"); then
|
||||||
eval set -- "$_input"
|
eval set -- "$_input"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--skip-check-installed)
|
--skip-check-installed)
|
||||||
skip_check_installed=1
|
skip_check_installed=1
|
||||||
;;
|
;;
|
||||||
|
--allow-downgrades)
|
||||||
|
[[ "$ID" =~ (debian|ubuntu|linuxmint|neon) ]] && install_flags+=(--allow-downgrades)
|
||||||
|
;;
|
||||||
--nogpgcheck)
|
--nogpgcheck)
|
||||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
install_flags+=(--nogpgcheck)
|
install_flags+=(--nogpgcheck)
|
||||||
@@ -334,7 +344,7 @@ installPackage() {
|
|||||||
pkg_install_cmd="pkg_install ${install_flags[*]} ${pkg_array[*]}"
|
pkg_install_cmd="pkg_install ${install_flags[*]} ${pkg_array[*]}"
|
||||||
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
|
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
|
||||||
if ! eval "$pkg_install_cmd"; then
|
if ! eval "$pkg_install_cmd"; then
|
||||||
(( silent )) || err "Failed to install ${pkg_array[*]}. Attempting to continue..."
|
(( silent )) || err "Failed to install ${pkg_array[*]}. Attempting to continue"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -342,30 +352,67 @@ installPackage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Installs a package using the system package manager
|
||||||
|
# Arguments:
|
||||||
|
# One or more package names
|
||||||
|
# Options:
|
||||||
|
# --skip-check-installed: Do not check if package is already installed
|
||||||
|
# --nogpgcheck: Disable GPG checks for RPM based distros
|
||||||
|
# --allow-downgrades: Useful for installing compatability versions on DEB based distros
|
||||||
|
# --silent, -s: Do not report errors (useful if package is not strictly required and errors are noisy)
|
||||||
|
#######################################
|
||||||
|
installMCDEB() {
|
||||||
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
|
aquireDeb
|
||||||
|
|
||||||
|
declare mcdeb="$MCDEB"
|
||||||
|
declare pkg_install_cmd="installPackage --skip-check-installed --nogpgcheck"
|
||||||
|
if (( COMPAT_SWITCH )); then
|
||||||
|
declare extract_dir && extract_dir="$(mktemp -d)"
|
||||||
|
mcdeb="${MCDEB/.deb/.compat.deb}"
|
||||||
|
pushd "$extract_dir" &>/dev/null || return $?
|
||||||
|
ar x "$MCDEB"
|
||||||
|
tar -xJf "control.tar.xz"
|
||||||
|
# Remove minimum version specifiers from control file
|
||||||
|
sed -i 's/ ([^)]*)//g' "control"
|
||||||
|
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 $?
|
||||||
|
rm -rf "$extract_dir"
|
||||||
|
pkg_install_cmd+=" --allow-downgrades"
|
||||||
|
fi
|
||||||
|
pkg_install_cmd+=" $mcdeb"
|
||||||
|
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
|
||||||
|
eval "$pkg_install_cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Add the JRiver repository files
|
# Add the JRiver repository files
|
||||||
#######################################
|
#######################################
|
||||||
addRepo() {
|
addRepo() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
echo "Adding JRiver repository"
|
echo "Adding JRiver repository to package manager"
|
||||||
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
|
||||||
sudo bash -c 'cat <<- EOF > /etc/yum.repos.d/jriver.repo
|
declare sources_dir="/etc/yum.repos.d/"
|
||||||
|
sudo bash -c "cat <<- EOF > $sources_dir/jriver.repo
|
||||||
[jriver]
|
[jriver]
|
||||||
name=JRiver Media Center repo by BryanC
|
name=JRiver Media Center repo by BryanC
|
||||||
baseurl=https://repos.bryanroessler.com/jriver
|
baseurl=https://repos.bryanroessler.com/jriver
|
||||||
gpgcheck=0
|
gpgcheck=0
|
||||||
EOF'
|
EOF"
|
||||||
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
|
elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint|neon)$ ]]; then
|
||||||
# MVERSION depends on $BASE unless --mcversion is passed
|
|
||||||
installPackage wget
|
installPackage wget
|
||||||
declare sources_dir="/etc/apt/sources.list.d"
|
declare sources_dir="/etc/apt/sources.list.d"
|
||||||
[[ ! -d "$sources_dir" ]] && sudo mkdir -p "$sources_dir"
|
[[ ! -d $sources_dir ]] && sudo mkdir -p "$sources_dir"
|
||||||
sudo bash -c "cat <<- EOF > $sources_dir/mediacenter$MVERSION.list
|
sudo rm -rf "$sources_dir"/mediacenter*.list
|
||||||
|
sudo bash -c "cat <<- EOF > $sources_dir/jriver.list
|
||||||
deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main
|
deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main
|
||||||
EOF"
|
EOF"
|
||||||
#echo "deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $BASE main" > "$sources_dir/mediacenter$MVERSION.list" 2>&1
|
|
||||||
#sudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$MVERSION.list" -O "/etc/apt/sources.list.d/mediacenter$MVERSION.list" &>/dev/null
|
|
||||||
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | sudo apt-key add - &>/dev/null
|
wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | sudo apt-key add - &>/dev/null
|
||||||
elif [[ "$ID" =~ ^opensuse.* ]]; then
|
elif [[ "$ID" =~ ^opensuse.* ]]; then
|
||||||
sudo zypper addrepo --no-gpgcheck "https://repos.bryanroessler.com/jriver" jriver &>/dev/null
|
sudo zypper addrepo --no-gpgcheck "https://repos.bryanroessler.com/jriver" jriver &>/dev/null
|
||||||
@@ -379,14 +426,6 @@ addRepo() {
|
|||||||
installMCFromRepo() {
|
installMCFromRepo() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
echo "Installing JRiver Media Center $MCVERSION from repository."
|
|
||||||
echo "Future updates will be handled by your package manager."
|
|
||||||
|
|
||||||
if ! debug; then
|
|
||||||
echo "This may take a few minutes to complete."
|
|
||||||
echo "Use --debug for verbose output."
|
|
||||||
fi
|
|
||||||
|
|
||||||
addRepo
|
addRepo
|
||||||
|
|
||||||
# Update package list
|
# Update package list
|
||||||
@@ -397,6 +436,7 @@ installMCFromRepo() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Installing JRiver Media Center using your package manager"
|
||||||
pkg_install_cmd="installPackage --skip-check-installed --nogpgcheck $MCPKG"
|
pkg_install_cmd="installPackage --skip-check-installed --nogpgcheck $MCPKG"
|
||||||
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
|
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
|
||||||
eval "$pkg_install_cmd"
|
eval "$pkg_install_cmd"
|
||||||
@@ -416,30 +456,32 @@ acquireDeb() {
|
|||||||
|
|
||||||
# If deb file already exists, skip download
|
# If deb file already exists, skip download
|
||||||
if [[ -f "$MCDEB" ]]; then
|
if [[ -f "$MCDEB" ]]; then
|
||||||
echo "Using local DEB file: $MCDEB"
|
echo "Using local source DEB: $MCDEB"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -v BETAPASS ]]; then
|
if [[ -v BETAPASS ]]; then
|
||||||
echo "Checking beta repo..."
|
echo "Checking beta repo for DEB package"
|
||||||
if wget -q -O "$MCDEB" \
|
if wget -q -O "$MCDEB" \
|
||||||
"https://files.jriver.com/mediacenter/channels/v$MVERSION/beta/$BETAPASS/MediaCenter-$MCVERSION-amd64.deb"; then
|
"https://files.jriver.com/mediacenter/channels/v$MVERSION/beta/$BETAPASS/MediaCenter-$MCVERSION-amd64.deb"; then
|
||||||
echo "Found!"
|
echo "Found!"
|
||||||
fi
|
fi
|
||||||
elif echo "Checking test repo..." && wget -q -O "$MCDEB" \
|
elif echo "Checking test repo for DEB package" && wget -q -O "$MCDEB" \
|
||||||
"https://files.jriver.com/mediacenter/test/MediaCenter-$MCVERSION-amd64.deb"; then
|
"https://files.jriver.com/mediacenter/test/MediaCenter-$MCVERSION-amd64.deb"; then
|
||||||
echo "Found!"
|
echo "Found!"
|
||||||
# Else check latest repo
|
# Else check latest repo
|
||||||
elif echo "Checking latest repo..." && wget -q -O "$MCDEB" \
|
elif echo "Checking latest repo for DEB package" && wget -q -O "$MCDEB" \
|
||||||
"https://files.jriver.com/mediacenter/channels/v$MVERSION/latest/MediaCenter-$MCVERSION-amd64.deb"; then
|
"https://files.jriver.com/mediacenter/channels/v$MVERSION/latest/MediaCenter-$MCVERSION-amd64.deb"; then
|
||||||
echo "Found!"
|
echo "Found!"
|
||||||
else
|
else
|
||||||
err "Cannot find DEB file."
|
err "Cannot find DEB file"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "$MCDEB" ]]; then
|
if [[ -f "$MCDEB" ]]; then
|
||||||
err "Downloaded DEB file missing or corrupted."
|
echo "Downloaded MC $MCVERSION DEB to: $MCDEB"
|
||||||
|
else
|
||||||
|
err "Downloaded DEB file missing or corrupted"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -458,7 +500,7 @@ buildRPM() {
|
|||||||
|
|
||||||
# skip rebuilding the rpm if it already exists
|
# skip rebuilding the rpm if it already exists
|
||||||
if [[ -f "$MCRPM" ]]; then
|
if [[ -f "$MCRPM" ]]; then
|
||||||
echo "$MCRPM already exists. Skipping build step."
|
echo "$MCRPM already exists. Skipping build step"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -466,6 +508,11 @@ buildRPM() {
|
|||||||
|
|
||||||
# Use --target parameter override
|
# Use --target parameter override
|
||||||
id="${TARGET:-$ID}"
|
id="${TARGET:-$ID}"
|
||||||
|
if [[ ! "$id" =~ (fedora|centos|opensuse.*) ]]; then
|
||||||
|
err "The current RPM build target $id is not supported, manually specify with --target"
|
||||||
|
err "The DEB file is located at $MCDEB"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Load deb dependencies into array
|
# Load deb dependencies into array
|
||||||
IFS=',' read -ra requires <<< "$(dpkg-deb -f "$MCDEB" Depends)"
|
IFS=',' read -ra requires <<< "$(dpkg-deb -f "$MCDEB" Depends)"
|
||||||
@@ -609,13 +656,14 @@ buildRPM() {
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Run rpmbuild
|
# Run rpmbuild
|
||||||
echo "Building version $MCVERSION, please wait..."
|
echo "Building RPM for MC $MCVERSION, this may take awhile"
|
||||||
rpmbuild_cmd="rpmbuild --define=\"%_topdir $OUTPUTDIR\" --define=\"%_libdir /usr/lib\" -bb $OUTPUTDIR/SPECS/mediacenter.spec"
|
rpmbuild_cmd="rpmbuild --define=\"%_topdir $OUTPUTDIR\" --define=\"%_libdir /usr/lib\" -bb"
|
||||||
|
rpmbuild_cmd+=" $OUTPUTDIR/SPECS/mediacenter.spec"
|
||||||
debug "$rpmbuild_cmd" || rpmbuild_cmd+=" &>/dev/null"
|
debug "$rpmbuild_cmd" || rpmbuild_cmd+=" &>/dev/null"
|
||||||
if eval "$rpmbuild_cmd" && [[ -f "$MCRPM" ]] ; then
|
if eval "$rpmbuild_cmd" && [[ -f "$MCRPM" ]] ; then
|
||||||
echo "Build successful. The RPM file is located at: $MCRPM"
|
echo "Build successful. The RPM file is located at: $MCRPM"
|
||||||
else
|
else
|
||||||
err "Build failed."
|
err "Build failed"
|
||||||
# For automation, let's remove the source DEB and reaquire it on next run
|
# For automation, let's remove the source DEB and reaquire it on next run
|
||||||
# after failure in case it is corrupted or buggy
|
# after failure in case it is corrupted or buggy
|
||||||
[[ -f "$MCDEB" ]] && echo "Removing source DEB" && rm -f "$MCDEB"
|
[[ -f "$MCDEB" ]] && echo "Removing source DEB" && rm -f "$MCDEB"
|
||||||
@@ -729,7 +777,7 @@ restoreLicense() {
|
|||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Opens ports using the system firewall tool
|
# Opens ports using the system firewall tool
|
||||||
# Arguments
|
# Arguments:
|
||||||
# Pre-defined service to enable
|
# Pre-defined service to enable
|
||||||
#######################################
|
#######################################
|
||||||
openFirewall() {
|
openFirewall() {
|
||||||
@@ -770,7 +818,7 @@ openFirewall() {
|
|||||||
ports=$u_ports
|
ports=$u_ports
|
||||||
EOF"
|
EOF"
|
||||||
fi
|
fi
|
||||||
firewall_cmd app update "$1"
|
firewall_cmd app update "$1" &>/dev/null
|
||||||
firewall_cmd allow "$1" &>/dev/null
|
firewall_cmd allow "$1" &>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -863,12 +911,14 @@ setDisplay() {
|
|||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Create associated service variables based on service name
|
# Create associated service variables based on service name
|
||||||
|
# Arguments
|
||||||
|
# Pre-defined service to enable
|
||||||
#######################################
|
#######################################
|
||||||
setServiceVars() {
|
setServiceVars() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME USER_STRING
|
declare -g SERVICE_NAME SERVICE_FNAME TIMER_NAME TIMER_FNAME USER_STRING
|
||||||
declare -g SERVICE_TYPE"${SERVICE_TYPE:-system}"
|
declare -g SERVICE_TYPE="${SERVICE_TYPE:-system}"
|
||||||
declare service_dir="/usr/lib/systemd/$SERVICE_TYPE"
|
declare service_dir="/usr/lib/systemd/$SERVICE_TYPE"
|
||||||
|
|
||||||
if [[ "$USER" == "root" && "$SERVICE_TYPE" == "user" ]]; then
|
if [[ "$USER" == "root" && "$SERVICE_TYPE" == "user" ]]; then
|
||||||
@@ -917,7 +967,7 @@ setServiceVars() {
|
|||||||
service_jriver-mediacenter() {
|
service_jriver-mediacenter() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
setServiceVars
|
setServiceVars "${FUNCNAME[0]##*_}"
|
||||||
|
|
||||||
sudo bash -c "cat <<- EOF > $SERVICE_FNAME
|
sudo bash -c "cat <<- EOF > $SERVICE_FNAME
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -951,7 +1001,7 @@ service_jriver-mediacenter() {
|
|||||||
service_jriver-mediaserver() {
|
service_jriver-mediaserver() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
setServiceVars
|
setServiceVars "${FUNCNAME[0]##*_}"
|
||||||
|
|
||||||
service_jriver-mediacenter "/MediaServer"
|
service_jriver-mediacenter "/MediaServer"
|
||||||
}
|
}
|
||||||
@@ -963,7 +1013,7 @@ service_jriver-mediaserver() {
|
|||||||
service_jriver-xvnc() {
|
service_jriver-xvnc() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
setServiceVars
|
setServiceVars "${FUNCNAME[0]##*_}"
|
||||||
setDisplay
|
setDisplay
|
||||||
declare start_cmd
|
declare start_cmd
|
||||||
declare -g PORT=$(( NEXT_DISPLAYNUM + 5900 ))
|
declare -g PORT=$(( NEXT_DISPLAYNUM + 5900 ))
|
||||||
@@ -995,6 +1045,8 @@ service_jriver-xvnc() {
|
|||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF"
|
EOF"
|
||||||
|
|
||||||
|
debug "DONE"
|
||||||
|
|
||||||
systemctl_reload_cmd &&
|
systemctl_reload_cmd &&
|
||||||
systemctl_enable_cmd "$SERVICE_NAME" &&
|
systemctl_enable_cmd "$SERVICE_NAME" &&
|
||||||
echo "Xvnc running on localhost:$PORT" &&
|
echo "Xvnc running on localhost:$PORT" &&
|
||||||
@@ -1009,7 +1061,7 @@ service_jriver-xvnc() {
|
|||||||
service_jriver-x11vnc() {
|
service_jriver-x11vnc() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
setServiceVars
|
setServiceVars "${FUNCNAME[0]##*_}"
|
||||||
setDisplay
|
setDisplay
|
||||||
|
|
||||||
declare start_cmd
|
declare start_cmd
|
||||||
@@ -1069,9 +1121,9 @@ service_jriver-createrepo() {
|
|||||||
declare cr_user="${CREATEREPO_USER:$USER}"
|
declare cr_user="${CREATEREPO_USER:$USER}"
|
||||||
|
|
||||||
if [[ "$USER" != "$cr_user" ]]; then
|
if [[ "$USER" != "$cr_user" ]]; then
|
||||||
USER="root" SERVICE_TYPE="system" setServiceVars
|
USER="root" SERVICE_TYPE="system" setServiceVars "${FUNCNAME[0]##*_}"
|
||||||
else
|
else
|
||||||
setServiceVars
|
setServiceVars "${FUNCNAME[0]##*_}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo bash -c "cat <<-EOF > $SERVICE_FNAME
|
sudo bash -c "cat <<-EOF > $SERVICE_FNAME
|
||||||
@@ -1204,7 +1256,7 @@ service_jriver-createrepo() {
|
|||||||
# # Metadata.
|
# # Metadata.
|
||||||
# LABEL \
|
# LABEL \
|
||||||
# org.label-schema.name="jrivermc${jriver_release}" \
|
# org.label-schema.name="jrivermc${jriver_release}" \
|
||||||
# org.label-schema.description="Docker image for JRiver Media Center ${jriver_release}." \
|
# org.label-schema.description="Docker image for JRiver Media Center ${jriver_release}" \
|
||||||
# org.label-schema.version="${image_version}" \
|
# org.label-schema.version="${image_version}" \
|
||||||
# org.label-schema.vcs-url="https://gitlab.com/shiomax/jrivermc-docker" \
|
# org.label-schema.vcs-url="https://gitlab.com/shiomax/jrivermc-docker" \
|
||||||
# org.label-schema.schema-version="1.0"
|
# org.label-schema.schema-version="1.0"
|
||||||
@@ -1269,7 +1321,7 @@ uninstall() {
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug "Stopping and removing all associated Media Center services"
|
echo "Stopping and removing all Media Center services"
|
||||||
for service in $(compgen -A "function" "service"); do
|
for service in $(compgen -A "function" "service"); do
|
||||||
service="${service##service_}"
|
service="${service##service_}"
|
||||||
SERVICE_TYPE=system setServiceVars "$service";
|
SERVICE_TYPE=system setServiceVars "$service";
|
||||||
@@ -1297,16 +1349,15 @@ uninstall() {
|
|||||||
systemctl_reload_cmd
|
systemctl_reload_cmd
|
||||||
done
|
done
|
||||||
|
|
||||||
debug "Removing repo files"
|
echo "Removing repo files"
|
||||||
[[ -f "/etc/yum.repos.d/jriver.repo" ]] &&
|
sudo rm -rf \
|
||||||
sudo rm -f "/etc/yum.repos.d/jriver.repo"
|
"/etc/yum.repos.d/jriver.repo" \
|
||||||
[[ -f "/etc/apt/sources.list.d/jriver.list" ]] &&
|
/etc/apt/sources.list.d/{jriver,mediacenter}*.list # also remove legacy repo files
|
||||||
sudo rm -f "/etc/apt/sources.list.d/jriver.list"
|
|
||||||
if [[ "$ID" =~ ^opensuse.* ]]; then
|
if [[ "$ID" =~ ^opensuse.* ]]; then
|
||||||
sudo zypper rr jriver &>/dev/null
|
sudo zypper rr jriver &>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug "Removing firewall rules"
|
echo "Removing firewall rules"
|
||||||
if hash firewall-cmd 2>/dev/null; then
|
if hash firewall-cmd 2>/dev/null; then
|
||||||
if [[ -v debug ]]; then
|
if [[ -v debug ]]; then
|
||||||
debug "firewall_cmd --permanent --remove-service=jriver"
|
debug "firewall_cmd --permanent --remove-service=jriver"
|
||||||
@@ -1328,11 +1379,11 @@ uninstall() {
|
|||||||
sudo rm -f /etc/ufw/applications.d/jriver
|
sudo rm -f /etc/ufw/applications.d/jriver
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug "Uninstalling Media Center package"
|
echo "Uninstalling Media Center package"
|
||||||
mc_pkg_rm_cmd="pkg_remove $MCPKG"
|
mc_pkg_rm_cmd="pkg_remove $MCPKG"
|
||||||
debug "$mc_pkg_rm_cmd" || mc_pkg_rm_cmd+=" &>/dev/null"
|
debug "$mc_pkg_rm_cmd" || mc_pkg_rm_cmd+=" &>/dev/null"
|
||||||
if eval "$mc_pkg_rm_cmd"; then
|
if eval "$mc_pkg_rm_cmd"; then
|
||||||
echo "JRiver Media Center has been completely uninstalled."
|
echo "JRiver Media Center has been completely uninstalled"
|
||||||
echo "To remove your library files, run: rm -rf $HOME/.jriver"
|
echo "To remove your library files, run: rm -rf $HOME/.jriver"
|
||||||
echo "To remove your rpmbuild output files, run: rm -rf $OUTPUTDIR"
|
echo "To remove your rpmbuild output files, run: rm -rf $OUTPUTDIR"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -1356,7 +1407,7 @@ main() {
|
|||||||
getOS
|
getOS
|
||||||
|
|
||||||
# Some distros need external repos installed for MC libraries
|
# Some distros need external repos installed for MC libraries
|
||||||
if [[ "$ID" == "ubuntu|neon" ]]; then
|
if [[ "$ID" =~ (ubuntu|linuxmint|neon) ]]; then
|
||||||
echo "Adding universe repository"
|
echo "Adding universe repository"
|
||||||
if ! grep ^deb /etc/apt/sources.list|grep -q universe; then
|
if ! grep ^deb /etc/apt/sources.list|grep -q universe; then
|
||||||
sudo add-apt-repository universe
|
sudo add-apt-repository universe
|
||||||
@@ -1418,14 +1469,33 @@ main() {
|
|||||||
|
|
||||||
if (( REPO_INSTALL_SWITCH )); then
|
if (( REPO_INSTALL_SWITCH )); then
|
||||||
if [[ "$ID" =~ ^opensuse.*$ ]]; then
|
if [[ "$ID" =~ ^opensuse.*$ ]]; then
|
||||||
echo "A SUSE repository is not yet available."
|
echo "A SUSE repository is not yet available"
|
||||||
echo "Use --install rpm to build and install a SUSE RPM instead."
|
echo "Use --install rpm to build and install a SUSE RPM instead"
|
||||||
|
exit 1
|
||||||
|
elif installMCFromRepo; then
|
||||||
|
echo "JRiver Media Center installed successfully from repo"
|
||||||
|
symlinkCerts
|
||||||
|
restoreLicense
|
||||||
|
openFirewall "jriver"
|
||||||
|
else
|
||||||
|
err "JRiver Media Center installation from repo failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if installMCFromRepo; then
|
fi
|
||||||
echo "JRiver Media Center installed successfully"
|
|
||||||
|
if (( BUILD_SWITCH )); then
|
||||||
|
installPackage "wget" "dpkg" "rpm-build"
|
||||||
|
acquireDeb
|
||||||
|
if [[ "$TARGET" =~ ^(fedora|centos|opensuse.*) ]]; then
|
||||||
|
buildRPM
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( DEB_INSTALL_SWITCH )); then
|
||||||
|
if installMCDEB; then
|
||||||
|
echo "JRiver Media Center installed successfully from local deb"
|
||||||
else
|
else
|
||||||
err "JRiver Media Center installation failed"
|
err "JRiver Media Center installation from local deb failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
symlinkCerts
|
symlinkCerts
|
||||||
@@ -1433,40 +1503,12 @@ main() {
|
|||||||
openFirewall "jriver"
|
openFirewall "jriver"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( DEB_INSTALL_SWITCH )); then
|
|
||||||
acquireDeb
|
|
||||||
if (( COMPAT_SWITCH )); then
|
|
||||||
declare extract_dir && extract_dir="$(mktemp -d)"
|
|
||||||
ar x --output "$extract_dir" "$MCDEB"
|
|
||||||
tar -xJf "$extract_dir/control.tar.xz" -C "$extract_dir"
|
|
||||||
# Remove minimum version specifiers from control file
|
|
||||||
sed -i 's/ ([^)]*)//g' "$extract_dir/control"
|
|
||||||
sed -i 's/([^)]*)//g' "$extract_dir/control" # MC DEB package error
|
|
||||||
tar -cJf "$extract_dir/control.tar.xz" \
|
|
||||||
-C "$extract_dir" "control" "postinst"
|
|
||||||
declare mcdeb="$MCDEB.compat"
|
|
||||||
ar rcs "$mcdeb" "$extract_dir/debian-binary" "$extract_dir/control.tar.xz" "$extract_dir/data.tar.xz"
|
|
||||||
rm -rf "$extract_dir"
|
|
||||||
fi
|
|
||||||
pkg_install_cmd="installPackage --skip-check-installed --nogpgcheck ${mcdeb:-$MCDEB}"
|
|
||||||
debug "$pkg_install_cmd" || pkg_install_cmd+=" &>/dev/null"
|
|
||||||
eval "$pkg_install_cmd"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( RPM_BUILD_SWITCH )); then
|
|
||||||
installPackage "wget" "dpkg" "rpm-build"
|
|
||||||
acquireDeb
|
|
||||||
buildRPM
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( RPM_INSTALL_SWITCH )); then
|
if (( RPM_INSTALL_SWITCH )); then
|
||||||
|
|
||||||
#rpm --upgrade "$MCRPM" # TODO, maybe universalize for RPM distros
|
#rpm --upgrade "$MCRPM" # TODO, maybe universalize for RPM distros
|
||||||
|
|
||||||
if installPackage --skip-check-installed --nogpgcheck "$MCRPM"; then
|
if installPackage --skip-check-installed --nogpgcheck "$MCRPM"; then
|
||||||
echo "JRiver Media Center installed successfully"
|
echo "JRiver Media Center installed successfully from local RPM"
|
||||||
else
|
else
|
||||||
err "JRiver Media Center installation failed"
|
err "JRiver Media Center installation from local RPM failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
symlinkCerts
|
symlinkCerts
|
||||||
|
|||||||
Reference in New Issue
Block a user