installJRMC 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. #!/usr/bin/env bash
  2. # This script will install JRiver Media Center and associated services
  3. # on Fedora, CentOS, Debian, and Ubuntu
  4. # Copyright (c) 2021 Bryan C. Roessler
  5. # This software is released under the Apache License.
  6. # https://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Use installJRMC --help to see available options or
  9. # read printHelp() below.
  10. #
  11. # TODO:
  12. # 1. Raspberry Pi OS support
  13. # 2. Interactive installation (ncurses?)
  14. # 3. Additional containerization
  15. shopt -s extglob
  16. _scriptversion="1.1.0"
  17. _outputdir="$PWD/output"
  18. _createrepo_webroot="/srv/jriver"
  19. _exec_user="$(whoami)"
  20. # Version control
  21. _boardurl="https://yabb.jriver.com/interact/index.php/board,71.0.html" # Media Center 28, only required if buildah is unavailable
  22. # _mcversion="28.0.84" # set manually
  23. printHelp() {
  24. debug "Running: ${FUNCNAME[0]}"
  25. cat <<- 'EOF'
  26. USAGE:
  27. installJRMC [[OPTION] [VALUE]]...
  28. If no options (besides -d) are provided, the script will default to '--install repo'.
  29. OPTIONS
  30. --install, -i repo|rpm
  31. repo: Install MC from repository, updates are handled by the system package manager
  32. rpm: Build and install RPM locally (RPM-based distros only)
  33. --build
  34. Build RPM from source DEB (but don't install it)
  35. --mcversion VERSION
  36. Specify the MC version, ex. "28.0.25" (Default: latest version)
  37. --outputdir PATH
  38. Generate rpmbuild output in this directory (Default: $PWD/output)
  39. --restorefile RESTOREFILE
  40. Restore file location for automatic license registration (Default: skip registration)
  41. --betapass PASSWORD
  42. Enter beta team password for access to beta builds
  43. --service, -s SERVICE
  44. See SERVICES section below for a list of possible services to install
  45. --service-user USER
  46. Install systemd services and containers for user USER (Default: current user)
  47. --container, -c CONTAINER (TODO: Under construction)
  48. See CONTAINERS section below for a list of possible services to install
  49. --createrepo
  50. Build rpm, copy to webroot, and run createrepo
  51. --createrepo-webroot PATH
  52. The webroot directory to install the repo (Default: /srv/jriver/)
  53. --createrepo-user USER
  54. The web server user (Default: current user)
  55. --version, -v
  56. Print this script version and exit
  57. --debug, -d
  58. Print debug output
  59. --help, -h
  60. Print help dialog and exit
  61. --uninstall, -u
  62. Uninstall JRiver MC, cleanup service files, and remove firewall rules (does not remove library files)
  63. SERVICES
  64. jriver-mediaserver
  65. Enable and start a mediaserver systemd service (requires an existing X server)
  66. jriver-mediacenter
  67. Enable and start a mediacenter systemd service (requires an existing X server)
  68. jriver-x11vnc
  69. Enable and start x11vnc for the local desktop (requires an existing X server)
  70. Usually combined with jriver-mediaserver or jriver-mediacenter services
  71. --vncpass and --display are optional (see 'jriver-xvnc-mediacenter' below)
  72. jriver-xvnc-mediacenter
  73. Enable and start a new Xvnc session running JRiver Media Center
  74. --vncpass PASSWORD
  75. Set vnc password for x11vnc/Xvnc access. If no password is set, the script
  76. will either use existing password stored in ~/.vnc/jrmc_passwd or use no password
  77. --display DISPLAY
  78. Display to start x11vnc/Xvnc (Default: The current display (x11vnc) or the
  79. current display incremented by 1 (Xvnc))
  80. jriver-createrepo
  81. Install hourly service to build latest MC RPM and run createrepo
  82. CONTAINERS (TODO: Under construction)
  83. mediacenter-xvnc
  84. createrepo
  85. EOF
  86. }
  87. init() {
  88. debug "Running: ${FUNCNAME[0]}"
  89. getOS
  90. # Agnostic commands
  91. bash_cmd(){ ifSudo bash -c "$@"; }
  92. rm_cmd(){ ifSudo rm -rf "$@"; }
  93. #cp_cmd(){ ifSudo cp -n "$@"; }
  94. mkdir_cmd(){ ifSudo mkdir -p "$@"; }
  95. ln_cmd(){ ifSudo ln -s "$@"; }
  96. systemctl_reload(){ ifSudo systemctl daemon-reload; }
  97. systemctl_enable(){ ifSudo systemctl enable --now "$@"; }
  98. systemctl_disable(){ ifSudo systemctl disable --now "$@"; }
  99. # OS-specific commands
  100. if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
  101. pkg_install(){ ifSudo dnf install -y "$@"; }
  102. pkg_reinstall(){ ifSudo dnf reinstall -y "$@"; }
  103. pkg_install_nogpg(){ ifSudo dnf install --nogpgcheck -y "$@"; }
  104. pkg_remove(){ ifSudo dnf remove -y "$@"; }
  105. pkg_update(){ ifSudo dnf makecache; }
  106. pkg_query(){ ifSudo rpm -q "$@"; }
  107. firewall_cmd(){ ifSudo firewall-cmd "$@"; }
  108. elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
  109. pkg_install(){ ifSudo apt-get install -y -q0 "$@"; }
  110. pkg_reinstall(){ ifSudo apt-get reinstall -y -q0 "$@"; }
  111. pkg_install_nogpg(){ ifSudo apt-get install -y -q0 "$@"; }
  112. pkg_remove(){ ifSudo apt-get remove --auto-remove -y -q0 "$@"; }
  113. pkg_update(){ ifSudo apt-get update -y -q0; }
  114. pkg_query(){ ifSudo dpkg -s "$@"; }
  115. firewall_cmd(){ ifSudo ufw "$@"; }
  116. fi
  117. parseInput "$@"
  118. _service_user="${_service_user:-$_exec_user}"
  119. _createrepo_user="${_createrepo_user:-$_exec_user}"
  120. # Set package aliases
  121. if [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
  122. declare -Ag PKG_ALIASES
  123. PKG_ALIASES["xorg-x11-utils"]="xorg-x11"
  124. PKG_ALIASES["rpm-build"]="rpm"
  125. PKG_ALIASES["createrepo_c"]="createrepo"
  126. PKG_ALIASES["tigervnc-server"]="tigervnc-standalone-server"
  127. fi
  128. # Install script dependencies
  129. [[ "$ID" == "centos" ]] && installPackage epel-release
  130. [[ ! -v _mcversion ]] && getLatestVersion
  131. [[ ! "$_mcversion" =~ ([0-9]+.[0-9]+.[0-9]+) ]] && echo "Invalid version number" && exit 1
  132. # Extract major version number
  133. _mversion="${_mcversion%%.*}"
  134. # Saving this substituion in case it's needed in the future
  135. # _variation="${_mcversion##*.}"
  136. }
  137. askOk() {
  138. local _response
  139. read -r -p "$* [y/N]" _response
  140. _response=${_response,,}
  141. [[ ! "$_response" =~ ^(yes|y)$ ]] && return 1
  142. return 0
  143. }
  144. debug() {
  145. if [[ -v _debug ]]; then
  146. if [[ $# -gt 0 ]]; then
  147. echo "Debug: $*"
  148. fi
  149. else
  150. return 1
  151. fi
  152. }
  153. err() { echo "Error: $*" >&2; }
  154. getOS() {
  155. debug "Running: ${FUNCNAME[0]}"
  156. if [[ -e "/etc/os-release" ]]; then
  157. source "/etc/os-release"
  158. else
  159. err "/etc/os-release not found"
  160. err "Your OS is unsupported"
  161. printHelp && exit 1
  162. fi
  163. debug "Platform: $ID $VERSION_ID"
  164. }
  165. ifSudo() {
  166. if [[ "$_exec_user" != "root" ]]; then
  167. sudo "$@"
  168. else
  169. "$@"
  170. fi
  171. }
  172. parseInput() {
  173. debug "Running: ${FUNCNAME[0]}"
  174. if [[ $# -eq 0 ]] || [[ $# -eq 1 && "$1" =~ ^(--debug|-d)$ ]]; then
  175. debug "No options passed, defaulting to repo installation method"
  176. _install="repo"
  177. fi
  178. if _input=$(getopt -o +i:vdhus:c: -l install:,build,outputdir:,mcversion:,restorefile:,betapass:,service-user:,service:,version,debug,help,uninstall,createrepo,createrepo-webroot:,createrepo-user:,vncpass:,display:,container:,tests -- "$@"); then
  179. eval set -- "$_input"
  180. while true; do
  181. case "$1" in
  182. --install|-i)
  183. shift
  184. _install="$1"
  185. if [[ "$_install" == "rpm" ]]; then
  186. if [[ ! "$ID" =~ ^(fedora|centos)$ ]]; then
  187. err "RPM install method not available on $ID"
  188. printHelp && exit 1
  189. fi
  190. _build=true
  191. fi
  192. ;;
  193. --build)
  194. _build=true
  195. ;;
  196. --outputdir)
  197. shift && _outputdir="$1"
  198. ;;
  199. --mcversion)
  200. shift && _mcversion="$1"
  201. ;;
  202. --restorefile)
  203. shift && _restorefile="$1"
  204. ;;
  205. --betapass)
  206. shift && _betapass="$1"
  207. ;;
  208. --service-user)
  209. shift && _service_user="$1"
  210. ;;
  211. --service|-s)
  212. shift && _services+=("$1")
  213. ;;
  214. --createrepo)
  215. _build=true
  216. _createrepo=true
  217. ;;
  218. --createrepo-webroot)
  219. shift && _createrepo_webroot="$1"
  220. ;;
  221. --createrepo-user)
  222. shift && _createrepo_user="$1"
  223. ;;
  224. --vncpass)
  225. shift && _vncpass="$1"
  226. ;;
  227. --display)
  228. shift && _display="$1"
  229. ;;
  230. --container|-c)
  231. shift && _containers+=("$1")
  232. ;;
  233. --version|-v)
  234. echo "Version: $_scriptversion"
  235. exit 0
  236. ;;
  237. --debug|-d)
  238. echo "Debugging on"
  239. echo "installJRMC version: $_scriptversion"
  240. _debug="true"
  241. ;;
  242. --help|-h)
  243. printHelp && exit $?
  244. ;;
  245. --uninstall|-u)
  246. _uninstall=true
  247. ;;
  248. --tests)
  249. echo "Running tests, all other options are skipped"
  250. tests
  251. ;;
  252. --)
  253. shift
  254. break
  255. ;;
  256. esac
  257. shift
  258. done
  259. else
  260. err "Incorrect options provided"
  261. printHelp && exit 1
  262. fi
  263. }
  264. getLatestVersion() {
  265. debug "Running: ${FUNCNAME[0]}"
  266. declare -g _mcversion _source
  267. # Use a containerized package manager
  268. debug "Getting latest version using containerized apt"
  269. [[ ! -x $(command -v buildah) ]] && installPackage buildah
  270. if [[ -x $(command -v buildah) ]] && CNT=$(buildah from ubuntu:18.04); then
  271. buildah run "$CNT" -- bash -c \
  272. "echo 'deb [trusted=yes arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ buster main' > /etc/apt/sources.list 2>&1"
  273. buildah run "$CNT" -- bash -c \
  274. "apt-get update --allow-insecure-repositories -y > /dev/null 2>&1"
  275. if _mcversion=$(buildah run "$CNT" -- apt-cache policy mediacenter?? | grep Candidate | awk '{print $2}' | sort -V | tail -n1); then
  276. _source="containerized package manager"
  277. fi
  278. buildah rm "$CNT" > /dev/null 2>&1
  279. # Else scrape from Interact
  280. elif _mcversion=$(wget -qO- "$_boardurl" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1); then
  281. _source="Interact scrape"
  282. fi
  283. if ! [[ -v _mcversion ]]; then
  284. err "MC version could not be determined. Please check the boardurl: $_boardurl or specify a version manually using --mcversion"
  285. exit 1
  286. fi
  287. }
  288. #######################################
  289. # Installs a package using the system package manager
  290. # Arguments:
  291. # One or more package names
  292. # Options:
  293. # --noquery, -n: Do not query the package state (useful if installing a local RPM)
  294. #######################################
  295. installPackage() {
  296. debug "Running: ${FUNCNAME[0]}" "$@"
  297. if _input=$(getopt -o +n -l noquery -- "$@"); then
  298. eval set -- "$_input"
  299. while true; do
  300. case "$1" in
  301. --noquery|-n)
  302. local _noquery="true"
  303. ;;
  304. --)
  305. shift
  306. break
  307. ;;
  308. esac
  309. shift
  310. done
  311. else
  312. err "Incorrect options provided"
  313. exit 1
  314. fi
  315. local -a _pkg_array _url_pkg_array
  316. local -a _pkg
  317. # Parse packages
  318. for _pkg in "$@"; do
  319. [[ -v PKG_ALIASES && -v PKG_ALIASES["$_pkg"] ]] && _pkg=PKG_ALIASES["$_pkg"]
  320. # Insert the package name to test if already installed
  321. if [[ -v _noquery ]] || ! pkg_query "$_pkg" > /dev/null 2>&1; then
  322. if [[ -v _url_pkg ]]; then
  323. _url_pkg_array+=("$_url_pkg")
  324. else
  325. _pkg_array+=("$_pkg")
  326. fi
  327. fi
  328. done
  329. # Install from package name (with gpg check)
  330. if [[ ${#_pkg_array[@]} -ge 1 ]]; then
  331. echo "Installing:" "${_pkg_array[@]}"
  332. if debug; then
  333. if ! pkg_install "${_pkg_array[@]}"; then
  334. err "Failed to install package. Attempting to continue..."
  335. return 1
  336. fi
  337. elif ! pkg_install "${_pkg_array[@]}" > /dev/null 2>&1; then
  338. err "Failed to install package. Attempting to continue..."
  339. return 1
  340. fi
  341. fi
  342. # Install from package url (without gpg check)
  343. if [[ ${#_url_pkg_array[@]} -ge 1 ]]; then
  344. echo "Installing: " "${_url_pkg_array[@]}"
  345. if debug; then
  346. if ! pkg_install_nogpg "${_url_pkg_array[@]}"; then
  347. err "Failed to install package. Attempting to continue..."
  348. return 1
  349. fi
  350. elif ! pkg_install_nogpg "${_url_pkg_array[@]}" > /dev/null 2>&1; then
  351. err "Failed to install package. Attempting to continue..."
  352. return 1
  353. fi
  354. fi
  355. }
  356. #######################################
  357. # Adds the JRiver repos
  358. #######################################
  359. addRepo() {
  360. debug "Running: ${FUNCNAME[0]}"
  361. if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
  362. bash_cmd 'cat <<- EOF > /etc/yum.repos.d/jriver.repo
  363. [jriver]
  364. name=JRiver Media Center repo by BryanC
  365. baseurl=https://repos.bryanroessler.com/jriver
  366. gpgcheck=0
  367. EOF'
  368. elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
  369. installPackage wget
  370. wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | ifSudo apt-key add - > /dev/null 2>&1
  371. ifSudo wget "http://dist.jriver.com/latest/mediacenter/mediacenter$_mversion.list" -O "/etc/apt/sources.list.d/mediacenter$_mversion.list" > /dev/null 2>&1
  372. fi
  373. }
  374. #######################################
  375. # Installs JRiver Media Center from a repository
  376. #######################################
  377. installMCFromRepo() {
  378. debug "Running: ${FUNCNAME[0]}"
  379. local _mcpkg
  380. echo "Installing JRiver Media Center $_mcversion from repo..."
  381. if ! debug; then
  382. echo "This may take a few minutes to complete"
  383. echo "Use --debug for verbose output"
  384. fi
  385. addRepo
  386. # Update package list
  387. debug "Updating package list"
  388. if ! pkg_update > /dev/null 2>&1; then
  389. err "Package update failed!"
  390. exit 1
  391. fi
  392. if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
  393. _mcpkg="MediaCenter"
  394. elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
  395. _mcpkg="mediacenter$_mversion"
  396. fi
  397. if [[ -v _specific_version ]]; then
  398. if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
  399. if debug; then
  400. installPackage "$_mcpkg-$_mcversion"
  401. else
  402. installPackage "$_mcpkg-$_mcversion" > /dev/null 2>&1
  403. fi
  404. elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
  405. if debug; then
  406. installPackage "$_mcpkg=$_mcversion"
  407. else
  408. installPackage "$_mcpkg=$_mcversion" > /dev/null 2>&1
  409. fi
  410. fi
  411. else
  412. if debug; then
  413. installPackage "$_mcpkg"
  414. else
  415. installPackage "$_mcpkg" > /dev/null 2>&1
  416. fi
  417. fi
  418. return $?
  419. }
  420. #######################################
  421. # Acquire the source DEB package from JRiver's servers
  422. #######################################
  423. acquireDeb() {
  424. debug "Running: ${FUNCNAME[0]}"
  425. declare -g DEBFILENAME
  426. DEBFILENAME="$_outputdir/SOURCES/MediaCenter-$_mcversion-amd64.deb"
  427. # If necessary, create SOURCES dir
  428. [[ ! -d "$_outputdir/SOURCES" ]] && mkdir -p "$_outputdir/SOURCES"
  429. # If deb file already exists, skip download
  430. if [[ -f "$DEBFILENAME" ]]; then
  431. echo "Using local DEB file: $DEBFILENAME"
  432. elif [[ -v _betapass ]]; then
  433. echo -n "Checking beta repo..."
  434. if wget -q -O "$DEBFILENAME" \
  435. "https://files.jriver.com/mediacenter/channels/v$_mversion/beta/$_betapass/MediaCenter-$_mcversion-amd64.deb"; then
  436. echo "Found!"
  437. fi
  438. elif echo -n "Checking test repo..." && wget -q -O "$DEBFILENAME" \
  439. "https://files.jriver.com/mediacenter/test/MediaCenter-$_mcversion-amd64.deb"; then
  440. echo "Found!"
  441. # Else check latest repo
  442. elif echo -n "Checking latest repo..." && wget -q -O "$DEBFILENAME" \
  443. "https://files.jriver.com/mediacenter/channels/v$_mversion/latest/MediaCenter-$_mcversion-amd64.deb"; then
  444. echo "Found!"
  445. else
  446. err "Cannot find DEB file. Exiting..."
  447. exit 1
  448. fi
  449. if [[ ! -f "$DEBFILENAME" ]]; then
  450. err "Downloaded DEB file missing or corrupted, exiting..."
  451. exit 1
  452. fi
  453. }
  454. #######################################
  455. # Creates a SPEC file and builds the RPM from the source DEB using rpmbuild
  456. #######################################
  457. buildRPM() {
  458. debug "Running: ${FUNCNAME[0]}"
  459. # install build dependencies
  460. installPackage wget dpkg rpm-build
  461. # If necessary, make build directories
  462. [[ ! -d "$_outputdir/SPECS" ]] && mkdir -p "$_outputdir/SPECS"
  463. # rpmbuild uses rpm to check for build dependencies
  464. # this will fail on non-rpm distros
  465. if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
  466. local _build_requires=$'BuildRequires: rpm >= 4.11.0\nBuildRequires: dpkg'
  467. fi
  468. # Create spec file
  469. cat <<- EOF > "$_outputdir/SPECS/mediacenter.spec"
  470. Name: MediaCenter
  471. Version: $_mcversion
  472. Release: 1
  473. Summary: JRiver Media Center
  474. Group: Applications/Media
  475. Source0: http://files.jriver.com/mediacenter/channels/v$_mversion/latest/MediaCenter-$_mcversion-amd64.deb
  476. ${_build_requires:-}
  477. BuildArch: x86_64
  478. %define _rpmfilename %%{ARCH}/%%{NAME}-%%{version}.%%{ARCH}.rpm
  479. AutoReq: 0
  480. Requires: glibc >= 2.28
  481. Requires: alsa-lib >= 1.1.8
  482. Requires: libuuid >= 2.33
  483. Requires: libX11 >= 1.6
  484. Requires: libX11-common >= 1.6
  485. Requires: libXext >= 1.3
  486. Requires: libxcb >= 1.1
  487. Requires: libXdmcp >= 1.1
  488. Requires: libstdc++ >= 7.4
  489. Requires: gtk3 >= 3.24
  490. Requires: mesa-libGL
  491. Requires: libglvnd-glx
  492. Requires: pango >= 1.42
  493. Requires: nss >= 3.42
  494. Requires: nspr >= 4.20
  495. Requires: python3
  496. Requires: xdg-utils
  497. Requires: libgomp >= 7.4
  498. Requires: fribidi >= 1.0.5
  499. Requires: fontconfig >= 2.13
  500. Requires: freetype >= 2.9.1
  501. Requires: harfbuzz >= 2.3.1
  502. Requires: mesa-libgbm >= 18.3.6
  503. Requires: libva >= 2.4.0
  504. Requires: libepoxy >= 1.5.3
  505. Requires: lcms2 >= 2.9
  506. Requires: vulkan-headers >= 1.1
  507. Requires: mesa-vulkan-drivers
  508. Requires: ca-certificates
  509. Requires: libXScrnSaver
  510. Recommends: vorbis-tools >= 1.4.0
  511. Recommends: lame >= 3.0
  512. Provides: mediacenter$_mversion
  513. License: Copyright 1998-2021, JRiver, Inc. All rights reserved. Protected by U.S. patents #7076468 and #7062468
  514. URL: http://www.jriver.com/
  515. %define __provides_exclude_from ^%{_libdir}/jriver/.*/.*\\.so.*$
  516. %description
  517. Media Center is more than a world class player.
  518. %global __os_install_post %{nil}
  519. %prep
  520. %build
  521. %install
  522. dpkg -x %{S:0} %{buildroot}
  523. %post -p /sbin/ldconfig
  524. %postun -p /sbin/ldconfig
  525. %files
  526. %{_bindir}/mediacenter$_mversion
  527. %{_libdir}/jriver
  528. %{_datadir}
  529. %exclude %{_datadir}/applications/media_center_packageinstaller_$_mversion.desktop
  530. /etc/security/limits.d/*
  531. EOF
  532. declare -g _mcrpm="$_outputdir/RPMS/x86_64/MediaCenter-$_mcversion.x86_64.rpm"
  533. # skip rebuilding the rpm if it already exists
  534. if [[ -f "$_mcrpm" ]]; then
  535. echo "$_mcrpm already exists. Skipping build step..."
  536. return 0
  537. fi
  538. # Run rpmbuild
  539. echo "Building version $_mcversion, please wait..."
  540. if debug; then
  541. rpmbuild --define="%_topdir $_outputdir" --define="%_libdir /usr/lib" -bb "$_outputdir/SPECS/mediacenter.spec"
  542. else
  543. rpmbuild --quiet --define="%_topdir $_outputdir" --define="%_libdir /usr/lib" -bb "$_outputdir/SPECS/mediacenter.spec" > /dev/null 2>&1
  544. fi
  545. return $?
  546. }
  547. #######################################
  548. # Copy the RPM to createrepo-webroot and runs createrepo as the createrepo-user
  549. #######################################
  550. runCreaterepo() {
  551. debug "Running: ${FUNCNAME[0]}"
  552. # Some additional commands specifically for createrepo (primarily to handle user rights)
  553. if [[ $_createrepo_user != "root" ]]; then
  554. if [[ -d "$_createrepo_webroot/repodata" ]]; then
  555. createrepo_cmd(){ sudo -u "$_createrepo_user" createrepo -q --update "$@"; }
  556. else
  557. createrepo_cmd(){ sudo -u "$_createrepo_user" createrepo -q "$@"; }
  558. fi
  559. cr_mkdir_cmd(){ sudo -u "$_createrepo_user" mkdir -p "$@"; }
  560. cr_cp_cmd(){ sudo -u "$_createrepo_user" cp -n "$@"; }
  561. else
  562. if [[ -d "$_createrepo_webroot/repodata" ]]; then
  563. createrepo_cmd(){ createrepo -q --update "$@"; }
  564. else
  565. createrepo_cmd(){ createrepo -q "$@"; }
  566. fi
  567. fi
  568. installPackage createrepo_c
  569. # If the webroot does not exist, create it
  570. if [[ ! -d "$_createrepo_webroot" ]]; then
  571. if ! cr_mkdir_cmd "$_createrepo_webroot"; then
  572. err "Could not create the createrepo-webroot path!"
  573. err "Make sure that the createrepo-webroot is writeable by createrepo-user: $_createrepo_user"
  574. return 1
  575. fi
  576. fi
  577. # Copy built rpms to webroot
  578. if ! cr_cp_cmd -f "$_mcrpm" "$_createrepo_webroot"; then
  579. err "Could not copy the RPM to the createrepo-webroot path"
  580. err "Make sure that the createrepo-webroot path is writeable by createrepo-user: $_createrepo_user"
  581. return 1
  582. fi
  583. # Run createrepo
  584. if createrepo_cmd "$_createrepo_webroot"; then
  585. echo "Successfully updated repo"
  586. return 0
  587. else
  588. err "Update repo failed"
  589. return 1
  590. fi
  591. }
  592. #######################################
  593. # Symlink certificates where JRiver Media Center expects them to be on Fedora/CentOS
  594. #######################################
  595. symlinkCerts() {
  596. debug "Running: ${FUNCNAME[0]}"
  597. if [[ ! -f /etc/ssl/certs/ca-certificates.crt && \
  598. -f /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem ]]; then
  599. if ! ln_cmd /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/ssl/certs/ca-certificates.crt; then
  600. err "Symlinking certificates failed"
  601. return 1
  602. fi
  603. fi
  604. }
  605. #######################################
  606. # Automatically restore the mjr license file if it is found next to
  607. # installJRMC or _restorefile is set
  608. #######################################
  609. restoreLicense() {
  610. debug "Running: ${FUNCNAME[0]}"
  611. local _mjr
  612. # Allow user to put the mjr file next to installJRMC
  613. if [[ ! -v _restorefile ]]; then
  614. for _mjr in "$PWD"/*.mjr; do
  615. [[ $_mjr -nt $_restorefile ]] && _restorefile="$_mjr"
  616. done
  617. fi
  618. # Restore license
  619. if [[ -f "$_restorefile" ]]; then
  620. if ! "mediacenter$_mversion" /RestoreFromFile "$_restorefile"; then
  621. err "Automatic license restore failed"
  622. return 1
  623. fi
  624. fi
  625. }
  626. #######################################
  627. # Opens ports using the system firewall tool
  628. # Arguments
  629. # Pre-defined service to enable
  630. #######################################
  631. openFirewall() {
  632. debug "Running: ${FUNCNAME[0]}" "$@"
  633. # Create OS-specific port rules based on argument (service) name
  634. local -a _f_ports # for firewall-cmd
  635. local _u_ports # for ufw
  636. if [[ "$1" == "jriver" ]]; then
  637. _f_ports=("52100-52200/tcp" "1900/udp")
  638. _u_ports="52100:52200/tcp|1900/udp"
  639. elif [[ "$1" =~ ^(jriver-x11vnc|jriver-xvnc)$ ]]; then
  640. _f_ports=("$_port/tcp" "1900/udp")
  641. _u_ports="$_port/tcp|1900/udp"
  642. fi
  643. # Open the ports
  644. if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
  645. [[ ! -x $(command -v firewall-cmd) ]] && installPackage firewalld
  646. if ! firewall_cmd --get-services | grep -q "$1"; then
  647. firewall_cmd --permanent --new-service="$1" > /dev/null 2>&1
  648. firewall_cmd --permanent --service="$1" --set-description="$1 installed by installJRMC" > /dev/null 2>&1
  649. firewall_cmd --permanent --service="$1" --set-short="$1" > /dev/null 2>&1
  650. for _f_port in "${_f_ports[@]}"; do
  651. firewall_cmd --permanent --service="$1" --add-port="$_f_port" > /dev/null 2>&1
  652. done
  653. firewall_cmd --add-service "$1" --permanent > /dev/null 2>&1
  654. firewall_cmd --reload > /dev/null 2>&1
  655. fi
  656. elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
  657. # Debian ufw package state is broken on fresh installations
  658. [[ ! -x $(command -v ufw) ]] && installPackage ufw
  659. if [[ ! -f "/etc/ufw/applications.d/$1" ]]; then
  660. bash_cmd "cat <<- EOF > /etc/ufw/applications.d/$1
  661. [$1]
  662. title=$1
  663. description=$1 installed by installJRMC
  664. ports=$_u_ports
  665. EOF"
  666. fi
  667. firewall_cmd app update "$1"
  668. firewall_cmd allow "$1" > /dev/null 2>&1
  669. fi
  670. # shellcheck disable=SC2181 # More concise
  671. if [[ $? -ne 0 ]]; then
  672. err "Firewall ports could not be opened"
  673. return 1
  674. fi
  675. }
  676. #######################################
  677. # Create the x11vnc password file
  678. #######################################
  679. setX11VNCPass() {
  680. debug "Running: ${FUNCNAME[0]}"
  681. _vncpassfile="$HOME/.vnc/jrmc_passwd"
  682. [[ ! -d "${_vncpassfile%/*}" ]] && mkdir -p "${_vncpassfile%/*}"
  683. if [[ -f "$_vncpassfile" ]]; then
  684. if [[ ! -v _vncpass ]]; then
  685. err "Refusing to overwrite existing $_vncpassfile with an empty password"
  686. err "Remove existing $_vncpassfile or set --vncpass to use an empty password"
  687. exit 1
  688. else
  689. rm -f "$_vncpassfile"
  690. fi
  691. fi
  692. if [[ -v _vncpass ]]; then
  693. if ! x11vnc -storepasswd "$_vncpass" "$_vncpassfile"; then
  694. err "Could not create VNC password file"
  695. return 1
  696. fi
  697. else
  698. _novncauth="true"
  699. fi
  700. }
  701. #######################################
  702. # Create the Xvnc password file
  703. #######################################
  704. setVNCPass() {
  705. debug "Running: ${FUNCNAME[0]}"
  706. _vncpassfile="$HOME/.vnc/jrmc_passwd"
  707. [[ ! -d "${_vncpassfile%/*}" ]] && mkdir -p "${_vncpassfile%/*}"
  708. if [[ -f "$_vncpassfile" ]]; then
  709. if [[ ! -v _vncpass ]]; then
  710. err "Refusing to overwrite existing $_vncpassfile with an empty password"
  711. err "Remove existing $_vncpassfile or set --vncpass to use an empty password"
  712. exit 1
  713. else
  714. rm -f "$_vncpassfile"
  715. fi
  716. fi
  717. if [[ -v _vncpass ]]; then
  718. if ! echo "$_vncpass" | vncpasswd -f > "$_vncpassfile"; then
  719. err "Could not create VNC password file"
  720. return 1
  721. fi
  722. else
  723. _novncauth="true"
  724. fi
  725. }
  726. #######################################
  727. # Set display and port variables
  728. #######################################
  729. setDisplay() {
  730. debug "Running: ${FUNCNAME[0]}"
  731. # Check _display, else DISPLAY, else set to :0 by default
  732. if [[ -v _display ]]; then
  733. _next_display="$_display"
  734. elif [[ -v DISPLAY ]]; then
  735. _display="${DISPLAY}"
  736. _displaynum="${_display#:}" # strip colon
  737. _displaynum="${_displaynum%.*}" # strip suffix
  738. _next_displaynum=$(( _displaynum + 1 ))
  739. _next_display=":$_next_displaynum"
  740. else
  741. _display=":0"
  742. _next_display=":1"
  743. fi
  744. _displaynum="${_display#:}" # strip colon
  745. _displaynum="${_displaynum%.*}" # strip suffix
  746. _next_displaynum=$(( _displaynum + 1 ))
  747. }
  748. #######################################
  749. # Create associated service variables based on service name
  750. #######################################
  751. servicePrep() {
  752. debug "Running: ${FUNCNAME[0]}"
  753. if [[ "$_service_user" == "root" ]]; then
  754. _service_fname="/usr/lib/systemd/system/${1}.service"
  755. _timer_fname="/usr/lib/systemd/system/${1}.timer"
  756. _service_name="jriver-${1}.service"
  757. _timer_name="jriver-${1}}.timer"
  758. _user_specifier=""
  759. else
  760. _service_fname="/usr/lib/systemd/system/${1}@.service"
  761. _timer_fname="/usr/lib/systemd/system/${1}@.timer"
  762. _service_name="${1}@$_service_user.service"
  763. _timer_name="${1}@$_service_user.timer"
  764. _user_specifier="User=%I"
  765. fi
  766. }
  767. #######################################
  768. # Starts and enables (at startup) a JRiver Media Center service
  769. # Arguments:
  770. # Passes arguments as startup options to /usr/bin/mediacenter??
  771. #######################################
  772. service_jriver-mediacenter() {
  773. debug "Running: ${FUNCNAME[0]}"
  774. bash_cmd "cat <<- EOF > $_service_fname
  775. [Unit]
  776. Description=JRiver Media Center $_mversion
  777. After=graphical.target
  778. [Service]
  779. $_user_specifier
  780. Type=simple
  781. Environment=DISPLAY=$_display
  782. Environment=XAUTHORITY=$XAUTHORITY
  783. ExecStart=/usr/bin/mediacenter$_mversion $*
  784. Restart=always
  785. RestartSec=10
  786. KillSignal=SIGHUP
  787. TimeoutStopSec=30
  788. [Install]
  789. WantedBy=graphical.target
  790. EOF"
  791. systemctl_reload && \
  792. systemctl_enable "$_service_name" && \
  793. openFirewall "jriver"
  794. }
  795. #######################################
  796. # Starts and enables (at startup) a JRiver Media Server service
  797. #######################################
  798. service_jriver-mediaserver() {
  799. debug "Running: ${FUNCNAME[0]}"
  800. service_jriver-mediacenter "/MediaServer"
  801. }
  802. #######################################
  803. # Starts and enables (at startup) JRiver Media Center in a new Xvnc session
  804. #######################################
  805. service_jriver-xvnc-mediacenter() {
  806. debug "Running: ${FUNCNAME[0]}"
  807. installPackage tigervnc-server
  808. setVNCPass
  809. local _port=$(( _next_displaynum + 5900 ))
  810. if [[ -v _novncauth ]]; then
  811. _exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -name jriver$_next_display -SecurityTypes None -autokill -xstartup /usr/bin/mediacenter$_mversion"
  812. else
  813. _exec_start_cmd="/usr/bin/vncserver $_next_display -geometry 1440x900 -alwaysshared -rfbauth $HOME/.vnc/jrmc_passwd -autokill -xstartup /usr/bin/mediacenter$_mversion"
  814. fi
  815. bash_cmd "cat <<- EOF > $_service_fname
  816. [Unit]
  817. Description=Remote desktop service (VNC)
  818. After=syslog.target network.target
  819. [Service]
  820. Type=simple
  821. $_user_specifier
  822. ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill $_next_display > /dev/null 2>&1 || :'
  823. ExecStart=$_exec_start_cmd
  824. ExecStop=/usr/bin/vncserver -kill $_next_display
  825. Restart=always
  826. [Install]
  827. WantedBy=multi-user.target
  828. EOF"
  829. systemctl_reload && \
  830. systemctl_enable "$_service_name" && \
  831. echo "Xvnc running on localhost:$_port" && \
  832. openFirewall "jriver-xvnc" && \
  833. openFirewall "jriver"
  834. }
  835. #######################################
  836. # Starts and enables (at startup) JRiver Media Server and x11vnc sharing the local desktop
  837. #######################################
  838. service_jriver-x11vnc() {
  839. debug "Running: ${FUNCNAME[0]}"
  840. installPackage x11vnc
  841. setX11VNCPass
  842. local _port=$(( _displaynum + 5900 ))
  843. # Get current desktop resolution
  844. # TODO: may need to break this out into its own function and get smarter at identifying multi-monitors
  845. _getResolution() {
  846. debug "Running: ${FUNCNAME[0]}"
  847. installPackage xorg-x11-utils
  848. _res=$(xdpyinfo | grep dimensions | awk '{print $2}')
  849. }
  850. _getResolution
  851. if [[ -v _novncauth ]]; then
  852. _exec_start_cmd="/usr/bin/x11vnc -display $_display -noscr -geometry $_res -auth guess -forever -bg -nopw"
  853. else
  854. _exec_start_cmd="/usr/bin/x11vnc -display $_display -noscr -geometry $_res -auth guess -forever -bg -rfbauth $HOME/.vnc/jrmc_passwd"
  855. fi
  856. bash_cmd "cat <<-EOF > $_service_fname
  857. [Unit]
  858. Description=x11vnc
  859. After=multi.service
  860. [Service]
  861. $_user_specifier
  862. Type=forking
  863. Environment=DISPLAY=$_display
  864. ExecStart=$_exec_start_cmd
  865. Restart=always
  866. RestartSec=10
  867. [Install]
  868. WantedBy=multi-user.target
  869. EOF"
  870. systemctl_reload && \
  871. systemctl_enable "$_service_name" && \
  872. echo "x11vnc running on localhost:$_port" && \
  873. openFirewall "jriver-x11vnc"
  874. }
  875. #######################################
  876. # Starts and enables (at startup) an hourly service to build the latest version of JRiver Media
  877. # Center RPM from the source DEB and create/update an RPM repository
  878. #######################################
  879. service_jriver-createrepo() {
  880. debug "Running: ${FUNCNAME[0]}"
  881. bash_cmd "cat <<-EOF > $_service_fname
  882. [Unit]
  883. Description=Builds JRiver Media Center RPM file, moves it to the repo dir, and runs createrepo
  884. [Service]
  885. $_user_specifier
  886. ExecStart=$PWD/installJRMC --outputdir $_outputdir --createrepo --createrepo-webroot $_createrepo_webroot --createrepo-user $_createrepo_user
  887. [Install]
  888. WantedBy=default.target
  889. EOF"
  890. bash_cmd "cat <<-EOF > $_timer_fname
  891. [Unit]
  892. Description=Run JRiver MC rpmbuild hourly
  893. [Timer]
  894. OnCalendar=hourly
  895. Persistent=true
  896. [Install]
  897. WantedBy=timers.target
  898. EOF"
  899. systemctl_reload && \
  900. systemctl_enable "$_timer_name"
  901. }
  902. #######################################
  903. # CONTAINERS
  904. #######################################
  905. # containerCreaterepo() {
  906. # :
  907. # }
  908. # containerVNC() {
  909. # :
  910. # }
  911. # containerMC() {
  912. # installPackage buildah podman
  913. # cnt=$(buildah from docker.io/jlesage/baseimage-gui:debian-10)
  914. # podman_create_cmd=("podman" "create" "--name" "$CNAME")
  915. # buildah_config_cmd=("buildah" "config" \
  916. # "--author" "bryanroessler@gmail.com" \
  917. # "--label" "maintainer=$MAINTAINER" \
  918. # "--env" "TZ=$TZ" \
  919. # "--workingdir" "/app" \
  920. # "--cmd" "mediacenter$_mversion")
  921. # mkcdirs() {
  922. # local dir
  923. # for dir in "$@"; do
  924. # if [[ ! -d "$dir" ]]; then
  925. # if ! mkdir -p "$dir"; then
  926. # err "Could not create directory $dir, check your permissions"
  927. # fi
  928. # fi
  929. # if ! chcon -t container_file_t -R "$dir"; then
  930. # err "Could not set container_file_t attribute for $dir, check your permissions"
  931. # fi
  932. # done
  933. # }
  934. # mkcdirs "$HOME/.jriver"
  935. # podman_create_cmd+=("-v" "$HOME/.jriver:/root/.jriver")
  936. # podman_create_cmd+=("-v" "$DOWNLOAD_ROOT:/downloads:z")
  937. # podman_create_cmd+=("-v" "$MONITOR_ROOT/nzbs:/nzbs")
  938. # podman_create_cmd+=("-p" "${CONTAINER[HOST_PORT]}:${CONTAINER[CONTAINER_PORT]}")
  939. # brc() { buildah run "$1" "${@:2}" || return 1; }
  940. # brc add-pkg gnupg2 libxss1 wmctrl xdotool ca-certificates inotify-tools libgbm1
  941. # brc add-pkg --virtual .build-deps wget
  942. # brc sh -s <<- EOF
  943. # wget -q "http://dist.jriver.com/mediacenter@jriver.com.gpg.key" -O- | apt-key add - > /dev/null 2>&1
  944. # EOF
  945. # brc wget "http://dist.jriver.com/latest/mediacenter/mediacenter$_mversion.list" -O "/etc/apt/sources.list.d/mediacenter$_mversion.list"
  946. # brc apt-get update -y -q0
  947. # brc add-pkg "mediacenter$_mversion"
  948. # brc del-pkg .build-deps
  949. # }
  950. #######################################
  951. # Complete uninstall
  952. #######################################
  953. uninstall() {
  954. debug "Running: ${FUNCNAME[0]}"
  955. if ! askOk "Do you really want to uninstall JRiver Media Center?"; then
  956. echo "Cancelling uninstall..."
  957. exit 0
  958. fi
  959. # Uninstall services
  960. echo "Stopping and removing all associated Media Center services"
  961. for _service in $(compgen -A "function" "service"); do
  962. servicePrep "$_service"
  963. systemctl_disable "$_service_name"
  964. systemctl_disable "$_timer_name"
  965. [[ -f "$_service_fname" ]] && rm_cmd "$_service_fname"
  966. [[ -f "$_timer_fname" ]] && rm_cmd "$_timer_fname"
  967. done
  968. echo "Removing repo files"
  969. [[ -f "/etc/yum.repos.d/jriver.repo" ]] \
  970. && rm_cmd "/etc/yum.repos.d/jriver.repo"
  971. [[ -f "/etc/apt/sources.list.d/jriver.list" ]] \
  972. && rm_cmd "/etc/apt/sources.list.d/jriver.list"
  973. echo "Removing firewall rules"
  974. if [[ -x $(command -v firewall-cmd) ]]; then
  975. firewall_cmd --permanent --remove-service=jriver
  976. firewall_cmd --permanent --delete-service=jriver
  977. firewall_cmd --reload
  978. elif [[ -x $(command -v ufw) ]]; then
  979. firewall_cmd delete allow jriver
  980. [[ -f "/etc/ufw/applications.d/jriver" ]] \
  981. && rm_cmd /etc/ufw/applications.d/jriver
  982. fi
  983. echo "Uninstalling Media Center"
  984. if [[ "$ID" =~ ^(fedora|centos)$ ]]; then
  985. pkg_remove "MediaCenter"
  986. elif [[ "$ID" =~ ^(debian|ubuntu|linuxmint)$ ]]; then
  987. pkg_remove "mediacenter$_mversion"
  988. fi
  989. echo "JRiver Media Center has been completely uninstalled"
  990. echo "If you wish to remove your library files: rm -rf $HOME/.jriver"
  991. echo "If you wish to remove your rpmbuild output files: rm -rf $_outputdir"
  992. }
  993. tests() {
  994. # To test on Mint: sudo apt-get install -y spice-vdagent ca-certificates git
  995. exit $?
  996. }
  997. main() {
  998. debug "Running: ${FUNCNAME[0]}"
  999. init "$@"
  1000. # Uninstall and exit
  1001. if [[ -v _uninstall ]]; then
  1002. uninstall
  1003. exit $?
  1004. fi
  1005. # Install MC using package manager
  1006. if [[ -v _install && "$_install" == "repo" ]]; then
  1007. if ! installMCFromRepo; then
  1008. err "JRiver Media Center installation failed"
  1009. exit 1
  1010. else
  1011. echo "JRiver Media Center installed successfully"
  1012. fi
  1013. symlinkCerts
  1014. restoreLicense
  1015. openFirewall "jriver"
  1016. fi
  1017. # Build RPM from source deb package
  1018. if [[ -v _build ]]; then
  1019. acquireDeb
  1020. if ! buildRPM || [[ ! -f "$_mcrpm" ]] ; then
  1021. err "Build failed. Exiting..."
  1022. [[ -f "$DEBFILENAME" ]] && echo "Removing source DEB" && rm -f "$DEBFILENAME"
  1023. exit 1
  1024. else
  1025. echo "Build successful. The RPM file is located at: $_mcrpm"
  1026. fi
  1027. fi
  1028. # Run createrepo
  1029. if [[ -v _createrepo ]]; then
  1030. runCreaterepo
  1031. fi
  1032. # Install RPM
  1033. if [[ -v _install && "$_install" == "rpm" ]]; then
  1034. installPackage --noquery "$_mcrpm"
  1035. symlinkCerts
  1036. restoreLicense
  1037. openFirewall "jriver"
  1038. fi
  1039. # Install services
  1040. setDisplay
  1041. for _service in "${_services[@]}"; do
  1042. servicePrep "$_service"
  1043. if ! "service_$_service"; then
  1044. if [[ $? -eq 127 ]]; then
  1045. err "Service $_service does not exist, check your service name"
  1046. else
  1047. err "Failed to create service: $_service"
  1048. fi
  1049. fi
  1050. done
  1051. # Install containers
  1052. # for _container in "${_containers[@]}"; do
  1053. # if ! "_container_$_container"; then
  1054. # if [[ $? -eq 127 ]]; then
  1055. # err "Container $_container does not exist, check your container name"
  1056. # else
  1057. # err "Failed to create container: $_container"
  1058. # fi
  1059. # fi
  1060. # done
  1061. }
  1062. main "$@"