Browse Source

Update for MC28

bryan 3 years ago
parent
commit
16fb94124f
3 changed files with 103 additions and 61 deletions
  1. 1 0
      .gitignore
  2. 16 20
      README.md
  3. 86 41
      installJRMC

+ 1 - 0
.gitignore

@@ -3,3 +3,4 @@
 testing.sh
 testing.sh
 .lock
 .lock
 tests
 tests
+test-container.sh

+ 16 - 20
README.md

@@ -11,36 +11,32 @@ This program will install [JRiver Media Center](https://www.jriver.com/) and ass
 
 
 `installJRMC [--option [ARGUMENT]]`
 `installJRMC [--option [ARGUMENT]]`
 
 
-Running `installJRMC` without any options will install the latest version of JRiver Media Center from the official JRiver repository (Ubuntu/Debian) or my [unofficial repository](https://repos.bryanroessler.com/jriver/) (Fedora/CentOS) using the system package manager. If any other option is specified then the default install method will need to be specified using `--repo` or `--rpm`. This makes it possible to install services, containers, repos, etc. independent of Media Center.
+Running `installJRMC` without any options will install the latest version of JRiver Media Center from the official JRiver repository (Ubuntu/Debian) or my [unofficial repository](https://repos.bryanroessler.com/jriver/) (Fedora/CentOS) using the system package manager. If any other option is specified, then the default install method will need to be specified using `--install`. This makes it possible to install services, containers, repos, etc. independent of Media Center.
 
 
 ## Options
 ## Options
 
 
 Here is a list of possible options that can be passed to the script. You can always find the latest supported options by running `installJRMC --help`.
 Here is a list of possible options that can be passed to the script. You can always find the latest supported options by running `installJRMC --help`.
 
 
 ```text
 ```text
---repo
-    Install JRiver Media Center from repository using package manager
-    DEB-based OSes: Official package repository
-    RPM-based OSes: BryanC's unofficial repository
---rpm
-     Build RPM from source DEB and install it
---rpmbuild
-    Build RPM from source DEB but do not install
---outputdir PATH
-    Generate rpmbuild output in this directory (Default: $PWD/outputdir)
+--install, -i repo|rpm
+    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)
+--build
+    Build RPM from source DEB (no installation)
 --mcversion VERSION
 --mcversion VERSION
-    Build or install a specific version (Default: install the latest version)
+    Build or install a specific MC version, ex. "28.0.25"
+--outputdir PATH
+    Generate rpmbuild output in this directory (Default: $PWD/output)
 --restorefile RESTOREFILE
 --restorefile RESTOREFILE
-    Restore file location for registration (Default: skip registration)
+    Restore file location for automatic license registration (Default: skip registration)
 --betapass PASSWORD
 --betapass PASSWORD
     Enter beta team password for access to beta builds
     Enter beta team password for access to beta builds
 --service-user USER
 --service-user USER
-    Install systemd services and containers for USER
+    Install systemd services and containers for USER (Default: current user)
 --service, -s SERVICE
 --service, -s SERVICE
     See SERVICES section below for a list of possible services to install
     See SERVICES section below for a list of possible services to install
---container, -c CONTAINER
+--container, -c CONTAINER (TODO: Under construction)
     See CONTAINERS section below for a list of possible services to install
     See CONTAINERS section below for a list of possible services to install
-    TODO: Containers are a work-in-progress
 --createrepo
 --createrepo
     Build rpm, copy to webroot, and run createrepo
     Build rpm, copy to webroot, and run createrepo
 --createrepo-webroot PATH
 --createrepo-webroot PATH
@@ -105,11 +101,11 @@ It is possible to install multiple services at one time using multiple `--servic
 
 
     Installs the latest version of JRiver Media Center from the repository.
     Installs the latest version of JRiver Media Center from the repository.
 
 
-* `installJRMC --repo --service jriver-mediaserver`
+* `installJRMC --install repo --service jriver-mediaserver`
 
 
     Installs JRiver Media Center from the repository and starts/enables the /MediaServer service.
     Installs JRiver Media Center from the repository and starts/enables the /MediaServer service.
 
 
-* `installJRMC --rpm --restorefile /path/to/license.mjr --mcversion 26.0.56`
+* `installJRMC --install rpm --restorefile /path/to/license.mjr --mcversion 26.0.56`
 
 
     Builds JRiver Media Center version 26.0.56 RPM from the source DEB, installs it (RPM distros only), and activates it using the specified .mjr license file.
     Builds JRiver Media Center version 26.0.56 RPM from the source DEB, installs it (RPM distros only), and activates it using the specified .mjr license file.
 
 
@@ -121,11 +117,11 @@ It is possible to install multiple services at one time using multiple `--servic
 
 
     Installs the jriver-createrepo timer and service to build the RPM, move it to the webroot, and run createrepo as `www-user` hourly.
     Installs the jriver-createrepo timer and service to build the RPM, move it to the webroot, and run createrepo as `www-user` hourly.
 
 
-* `installJRMC --repo --service jriver-x11vnc --service jriver-mediacenter --vncpass "letmein"`
+* `installJRMC --install repo --service jriver-x11vnc --service jriver-mediacenter --vncpass "letmein"`
 
 
     Installs services to share the existing local desktop via VNC and automatically run Media Center on startup.
     Installs services to share the existing local desktop via VNC and automatically run Media Center on startup.
 
 
-* `installJRMC --repo --service jriver-xvnc-mediacenter --display ":2"`
+* `installJRMC --install repo --service jriver-xvnc-mediacenter --display ":2"`
 
 
     Installs an Xvnc server on display ':2' that starts Media Center.
     Installs an Xvnc server on display ':2' that starts Media Center.
 
 

+ 86 - 41
installJRMC

@@ -12,8 +12,8 @@ shopt -s extglob
 #
 #
 #######################################
 #######################################
 
 
-_scriptversion="0.9.6"
-_boardurl="https://yabb.jriver.com/interact/index.php/board,67.0.html"
+_scriptversion="1.0.0a1"
+_boardurl="https://yabb.jriver.com/interact/index.php/board,71.0.html"
 _outputdir="$PWD/output"
 _outputdir="$PWD/output"
 _createrepo_webroot="/srv/jriver"
 _createrepo_webroot="/srv/jriver"
 _exec_user="$(whoami)"
 _exec_user="$(whoami)"
@@ -25,23 +25,20 @@ _printHelpAndExit() {
 		USAGE:
 		USAGE:
 			installJRMC [[OPTION] [VALUE]]...
 			installJRMC [[OPTION] [VALUE]]...
 
 
-			If no options (besides -d) are provided, the script will default to --repo
+			If no options (besides -d) are provided, the script will default to '--install repo'
 
 
 		OPTIONS
 		OPTIONS
-			--repo
-				Install JRiver Media Center from repository using package manager
-				DEB-based OSes: JRiver official package repository
-				RPM-based OSes: BryanC unofficial repository
-			--rpm
-				Build RPM from source DEB and install it
-			--rpmbuild
+			--install, -i repo|rpm
+				repo: Install JRiver Media Center from repository ('repo'), future updates will be handled by the system package manager
+                rpm: Build and install rpm file locally ('rpm')
+			--build
 				Build RPM from source DEB (no installation)
 				Build RPM from source DEB (no installation)
-			--outputdir PATH
-				Generate rpmbuild output in this directory (Default: $PWD/outputdir)
 			--mcversion VERSION
 			--mcversion VERSION
 				Build or install a specific version (Default: install the latest version)
 				Build or install a specific version (Default: install the latest version)
+            --outputdir PATH
+				Generate rpmbuild output in this directory (Default: $PWD/output)
 			--restorefile RESTOREFILE
 			--restorefile RESTOREFILE
-				Restore file location for registration (Default: skip registration)
+				Restore file location for automatic license registration (Default: skip registration)
 			--betapass PASSWORD
 			--betapass PASSWORD
 				Enter beta team password for access to beta builds
 				Enter beta team password for access to beta builds
 			--service-user USER
 			--service-user USER
@@ -133,8 +130,8 @@ _init() {
 
 
     # Set defaults
     # Set defaults
     if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
     if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
-        debug "No options passed, defaulting to --repo installation method"
-        _repoinstall="true"
+        debug "No options passed, defaulting to repo installation method"
+        _install="repo"
     fi
     fi
 
 
     _service_user="${_service_user:-$_exec_user}"
     _service_user="${_service_user:-$_exec_user}"
@@ -169,7 +166,7 @@ _main() {
     fi
     fi
 
 
     # Install MC using package manager
     # Install MC using package manager
-    if [[ -v _repoinstall ]]; then
+    if [[ -v _install && "$_install" == "repo" ]]; then
         _installMCFromRepo
         _installMCFromRepo
         _symlinkCerts
         _symlinkCerts
         _restoreLicense
         _restoreLicense
@@ -177,7 +174,7 @@ _main() {
     fi
     fi
 
 
     # Build RPM from source deb package
     # Build RPM from source deb package
-    if [[ -v _rpmbuild ]]; then
+    if [[ -v _build ]]; then
         _acquireDeb
         _acquireDeb
         _buildRPM
         _buildRPM
     fi
     fi
@@ -188,7 +185,7 @@ _main() {
     fi
     fi
 
 
     # Install the rpm
     # Install the rpm
-    if [[ -v _rpminstall ]]; then
+    if [[ -v _install && "$_install" == "rpm" ]]; then
         _installPackage --noquery "$_mcrpm"
         _installPackage --noquery "$_mcrpm"
         _symlinkCerts
         _symlinkCerts
         _restoreLicense
         _restoreLicense
@@ -256,22 +253,23 @@ _ifSudo() {
 _parseInput() {
 _parseInput() {
     debug "Running: ${FUNCNAME[0]}"
     debug "Running: ${FUNCNAME[0]}"
 
 
-    if _input=$(getopt -o +vdhus:c: -l repo,rpm,rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container: -- "$@"); then
+    if _input=$(getopt -o +i:vdhus:c: -l install,rpmbuild,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container: -- "$@"); then
         eval set -- "$_input"
         eval set -- "$_input"
         while true; do
         while true; do
             case "$1" in
             case "$1" in
-                --repo)
-                    _repoinstall="true"
+                --install|-i)
+                    shift 
+                    _install="$1"
+                    if [[ "$_install" == "rpm" ]]; then
+                        if [[ ! "$ID" =~ ^(fedora|centos)$ ]]; then
+                            err "RPM install method not available on $ID"
+                            _printHelpAndExit 1
+                        fi
+                        _build="true"
+                    fi
                     ;;
                     ;;
-                --rpm)
-                    [[ ! "$ID" =~ ^(fedora|centos)$ ]] && \
-                        err "RPM installation not available on $ID" && \
-                        _printHelpAndExit 1
-                    _rpmbuild="true"
-                    _rpminstall="true"
-                    ;;
-                --rpmbuild)
-                    _rpmbuild="true"
+                --build)
+                    _build="true"
                     ;;
                     ;;
                 --outputdir)
                 --outputdir)
                     shift && _outputdir="$1"
                     shift && _outputdir="$1"
@@ -292,7 +290,7 @@ _parseInput() {
                     shift && _services+=("$1")
                     shift && _services+=("$1")
                     ;;
                     ;;
                 --createrepo)
                 --createrepo)
-                    _rpmbuild="true"
+                    _build="true"
                     _createrepo="true"
                     _createrepo="true"
                     ;;
                     ;;
                 --createrepo-webroot)
                 --createrepo-webroot)
@@ -492,7 +490,7 @@ _installMCFromRepo() {
         elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
         elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
             _installPackage wget
             _installPackage wget
             wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | _ifSudo apt-key add - > /dev/null 2>&1
             wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | _ifSudo apt-key add - > /dev/null 2>&1
-            _ifSudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$mversion.list" -O "/etc/apt/sources.list.d/mediacenter$mversion.list"
+            _ifSudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$_mversion.list" -O "/etc/apt/sources.list.d/mediacenter$_mversion.list"
         fi
         fi
     }
     }
     _addRepo
     _addRepo
@@ -1206,19 +1204,66 @@ _service_jriver-createrepo() {
 #######################################
 #######################################
 # CONTAINERS
 # CONTAINERS
 #######################################
 #######################################
-_containerCreaterepo() {
-    :
-}
+# _containerCreaterepo() {
+#     :
+# }
 
 
 
 
-_containerVNC() {
-    :
-}
+# _containerVNC() {
+#     :
+# }
 
 
 
 
-_containerMC() {
-    :
-}
+# _containerMC() {
+#     _installPackage buildah podman
+#     cnt=$(buildah from docker.io/jlesage/baseimage-gui:debian-10)
+#     podman_create_cmd=("podman" "create" "--name" "$CNAME")
+#     buildah_config_cmd=("buildah" "config" \
+#         "--author" "bryanroessler@gmail.com" \
+#         "--label" "maintainer=$MAINTAINER" \
+#         "--env" "TZ=$TZ" \
+#         "--workingdir" "/app" \
+#         "--cmd" "mediacenter$_mversion")
+
+#     mkcdirs() {
+#         local dir
+#         for dir in "$@"; do
+#             if [[ ! -d "$dir" ]]; then 
+#                 if ! mkdir -p "$dir"; then
+#                     err "Could not create directory $dir, check your permissions"
+#                 fi
+#             fi
+#             if ! chcon -t container_file_t -R "$dir"; then
+#                 err "Could not set container_file_t attribute for $dir, check your permissions"
+#             fi
+#         done
+#     }
+
+#     mkcdirs "$HOME/.jriver"
+
+#     podman_create_cmd+=("-v" "$HOME/.jriver:/root/.jriver")
+#     podman_create_cmd+=("-v" "$DOWNLOAD_ROOT:/downloads:z")
+#     podman_create_cmd+=("-v" "$MONITOR_ROOT/nzbs:/nzbs")
+#     podman_create_cmd+=("-p" "${CONTAINER[HOST_PORT]}:${CONTAINER[CONTAINER_PORT]}")
+
+#     brc() { buildah run "$1" "${@:2}" || return 1; }
+
+#     brc add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1
+
+#     brc add-pkg --virtual .build-deps wget
+
+#     brc sh -s <<- EOF
+# 		wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | apt-key add - > /dev/null 2>&1
+# 	EOF
+
+#     brc wget "http://dist.jriver.com/latest/mediacenter/mediacenter$_mversion.list" -O "/etc/apt/sources.list.d/mediacenter$_mversion.list"
+
+#     brc apt-get update -y -q0
+
+#     brc add-pkg "mediacenter$_mversion"
+
+#     brc del-pkg .build-deps
+# }
 
 
 
 
 #######################################
 #######################################