3 ####################################
6 # Ardour/Mixbus bundle installer
9 ###################################
15 PGM_EXEC_FILE="ardour3"
17 INSTALL_DEST_BASE="/opt"
18 USER_BIN_DIR="/usr/local/bin"
20 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
24 #### Global Variables ####
27 ########################
28 # Function Definitions
29 ########################
31 VaildateYesNoQuestion ()
38 until test "y" = $INPUT_OK;
41 read -p "$1 [y/n]: " USER_INPUT
44 if [ ! -z $USER_INPUT ];
46 if [ "Y" = $USER_INPUT -o "y" = $USER_INPUT -o "n" = $USER_INPUT -o "N" = $USER_INPUT ];
53 echo $USER_INPUT | tr '[:upper:]' '[:lower:]'
60 # Determine which software install app to use and then install requested package
63 if which yum > /dev/null;
65 ${SUPER} yum -y install $1
71 echo "!!! ERROR !!! yum install failed for an unknown reason."
72 echo "Please install package $1 after this installer completes."
76 elif which apt-get > /dev/null;
78 ${SUPER} apt-get -y install $1
84 echo "!!! ERROR !!! apt-get install failed for an unknown reason."
85 echo "Please install package $1 after this installer completes."
91 echo "!!! ERROR !!! - Not able to detect which software install tool to use (yum or apt-get)."
92 echo "Please install package $1 using the system software install tool."
101 ########################################################################
103 ########################################################################
106 # If you double click a script, some systems don't get the PWD correct.
107 # Force it to be correct
108 PKG_PATH=$(dirname "$(readlink -f "$0")")
112 echo "Welcome to the ${PGM_NAME} installer"
114 echo "${PGM_NAME} will be installed for user ${USER_NAME} in ${INSTALL_DEST_BASE}"
117 ###############################
118 # Check for install destination
119 ###############################
121 if [ ! -d ${INSTALL_DEST_BASE} ];
124 echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
125 echo "Installation will not complete."
127 read -p "Press ENTER to exit installer:" BLAH
131 #############################
132 # Check for root privileges
133 #############################
138 if [ "$(id -u)" != "0" ]; then
140 if ! which sudo > /dev/null;
143 echo "Sudo installed failed, attempting to install using su"
144 echo "Please enter root password below"
147 if ! su -c "./.stage2.run";
152 echo "This installer requires root privileges. It is currently not"
153 echo "running as root AND an attempt to use su failed."
155 echo "Please correct this by installing and configuring sudo or running"
156 echo "the installer as root (su -c)."
158 read -p "Press ENTER to exit installer:" BLAH
163 sudo -k # make sudo forget about cached credentials
169 echo "Attempting to install using su"
170 echo "Please enter root password below"
173 if ! su -c "./.stage2.run";
178 echo "This installer requires root privileges. It is currently not"
179 echo "running as root AND an attempt to use both sudo and su failed."
181 echo "Please correct this by installing and configuring sudo or running"
182 echo "the installer as root (su -c)."
184 read -p "Press ENTER to exit installer:" BLAH
191 # The quoting reqired for the su sanityCheck method does not work when used without
192 # su. Using sh -c in the normal case gets around that, but is a bit of a hack.
195 NORM_USER="su -l $USER_NAME -c"
198 ############################
199 # Determine processor type
200 ############################
203 i[3456789]86|x86|i86pc)
204 echo "Architecture is x86"
208 echo "Architecture is x86_64"
213 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
215 read -p "Press ENTER to exit installer:" BLAH
224 # We have to check the current folder and the INSTALL_DEST_BASE just
225 # in case they are on different devices
226 echo "Checking for required disk space"
228 if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
230 echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
231 echo "This package is broken or does not support ${ARCH}."
233 read -p "Press ENTER to exit installer:" BLAH
236 REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
238 #Installer needs 2x the space since the bundle is unpacked locally and then copied
239 REQUIRED_BYTES=$(($REQUIRED_BYTES + $REQUIRED_BYTES))
241 #Check space in current folder
242 FREE_BYTES=$(df -P -B 1 "${PKG_PATH}" | grep / | awk '{print $4}')
244 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
246 echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
247 echo "Install requires ${REQUIRED_BYTES} bytes and"
248 echo "there is only ${FREE_BYTES} bytes of free space"
250 read -p "Press ENTER to exit installer:" BLAH
254 #Check space in INSTALL_DEST_BASE
255 FREE_BYTES=$(df -P -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}')
257 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
259 echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}"
260 echo "Install requires ${REQUIRED_BYTES} bytes and"
261 echo "there is only ${FREE_BYTES} bytes of free space"
263 read -p "Press ENTER to exit installer:" BLAH
268 FILESYSTEM_TYPE=$(df -P -T "${PKG_PATH}" | grep / | awk '{print $2}')
269 echo "Bundle is on ${FILESYSTEM_TYPE} filesystem"
271 #####################
273 #####################
275 # untar the correct bundle for us to install
276 echo "Unpacking bundle for $ARCH"
278 if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
280 echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
282 read -p "Press ENTER to exit installer:" BLAH
286 if ! tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2; then
288 echo "!!! ERROR !!! Can't unpack ${ARCH} bundle file."
290 read -p "Press ENTER to exit installer:" BLAH
293 echo "Bundle unpacked"
296 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
299 #######################
300 # Check for xdg utils
301 #######################
303 #load the file that contains the translated names of the users directories
304 if [ -e /home/${USER_NAME}/.config/user-dirs.dirs ]; then
305 . /home/${USER_NAME}/.config/user-dirs.dirs
308 if [ "$(id -u)" != "0" ]; then
309 USER_DESKTOP_DIR=${XDG_DESKTOP_DIR:-$HOME/Desktop}
311 #running as root with su makes this more difficult
312 DESKTOP_FOLDER=$(echo ${XDG_DESKTOP_DIR:-$HOME/Desktop} | awk -F/ '{print $NF}')
313 USER_DESKTOP_DIR="/home/${USER_NAME}/${DESKTOP_FOLDER}"
316 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
317 if [ -z "$XDG_MENU_VER" ];
319 echo "System does not have xdg-desktop-menu installed"
323 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
324 if [ -z "$XDG_ICON_VER" ];
326 echo "System does not have xdg-icon-resource installed"
330 #################################################
331 # Check if system libs are OK (libc, etc)
332 #################################################
335 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
339 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
342 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
344 if [ -n "$LDD_RESULT" ];
351 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
353 for path in $LIB_FILES
355 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
356 if [ -n "$LDD_RESULT" ];
363 if test "T" = $LIB_ERROR;
366 echo "!!! ERROR !!! - Missing library detected!"
367 echo "This system does not have the correct libs to run ${PGM_NAME}."
368 echo "Installation will not complete. Please use a compatible distro."
370 read -p "Press ENTER to exit installer:" BLAH
374 ################################
375 # Setup derived variables
376 ################################
377 PGM_VERSION=$(echo ${BUNDLE_DIR} | cut -d- -f2)
378 PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | cut -d- -f3)
380 if [ -z ${PGM_BUILDTYPE} ];
382 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}"
383 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}" #no dash between name and version since dash seperates vendor from program
384 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop" #no dash between name and version since dash seperates vendor from program
385 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
387 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}"
388 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}" #no dash between name and version since dash seperates vendor from program
389 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop" #no dash between name and version since dash seperates vendor from program
390 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"
393 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
394 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share/icons"
395 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
397 ################################
398 # Install bundle and Menu/Link
399 ################################
401 # uninstall any older versions
402 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
403 if [ ! -z "$UNINSTALLERS" ];
405 for i in $UNINSTALLERS; do
407 echo "Found existing ${PGM_NAME} installation."
409 ANSWER=$(VaildateYesNoQuestion "Do you want to run the uninstaller ${i} ?")
411 if test "y" = $ANSWER;
414 echo "Running uninstaller $i"
426 echo "Installing ${PGM_NAME} ${PGM_VERSION} in ${INSTALL_DEST_BASE}"
429 # Copy the new version in the install directory
430 ${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
431 ${SUPER} cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
433 # write the desktop/menu file
434 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
435 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
436 echo "Version=1.0" >> /tmp/${MENU_FILE}
437 echo "Type=Application" >> /tmp/${MENU_FILE}
438 echo "Terminal=false" >> /tmp/${MENU_FILE}
439 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
440 if [ -z ${PGM_BUILDTYPE} ];
442 echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
444 echo "Name=${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}" >> /tmp/${MENU_FILE}
446 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
447 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
448 echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
450 chmod ugo+rx /tmp/${MENU_FILE}
451 ${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
453 # install the Menu, Link, and Icon(s)
454 if [ "T" = ${HAS_XDG} ];
456 echo "Adding ${PGM_NAME} to the applications menu"
457 ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
458 ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
459 ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
460 ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
461 ${SUPER} xdg-icon-resource install --context apps --size 256 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_256px.png ${ICON_NAME}
463 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
465 ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
468 ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
469 ${SUPER} xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
472 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
473 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
474 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
477 echo "Creating a desktop link for ${PGM_NAME} in ${USER_DESKTOP_DIR}"
478 cp ${MENU_FILE_PATH}/${MENU_FILE} ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
479 chmod ugo+rwx ${USER_DESKTOP_DIR}/${DESKTOP_LINK_FILE}
483 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
486 ${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
488 # Create link to the program in user bin
491 echo "Creating link ${PGM_NAME}3 in ${USER_BIN_DIR}"
494 if [ -d "${USER_BIN_DIR}" ]; then
495 if [ -e "${USER_BIN_DIR}/${PGM_NAME}3" ]; then
496 ${SUPER} rm -f ${USER_BIN_DIR}/${PGM_NAME}3
500 ${SUPER} ln -sf ${PGM_EXEC_PATH} ${PGM_NAME}3
504 echo "Can not create link because ${USER_BIN_DIR} does not exist"
507 ###########################
508 # Check Jack and qjackctl
509 ###########################
512 echo "Checking to see if Jack is installed"
517 if ! which jackd > /dev/null;
520 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
523 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
525 if test "y" = $ANSWER;
527 echo "Attempting to install Jack"
528 SystemInstall "jackd"
533 read -p "Press ENTER to continue:" BLAH
540 echo "Jack already present"
543 # Check to see if Jack is new enough to operate correctly.
545 if [ "t" = ${JACK_INSTALLED} ];
548 JACK_VER_STRING=$(jackd --version | grep -e "jackd.*protocol")
549 JACK_NAME=$(echo $JACK_VER_STRING | awk '{print $1}')
550 JACK_VERSION=$(echo $JACK_VER_STRING | awk '{print $3}')
551 JACK_VERSION_MAJOR=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $1}')
552 JACK_VERSION_MIDDLE=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $2}')
553 JACK_VERSION_MINOR=$(echo $JACK_VERSION | awk 'BEGIN{FS="."}{print $3}')
555 if [ "jackd" = ${JACK_NAME} ];
557 if [ ${JACK_VERSION_MAJOR} -eq 0 ];
559 if [ ${JACK_VERSION_MIDDLE} -eq 121 ];
561 if [ ${JACK_VERSION_MINOR} -ge 3 ];
565 elif [ ${JACK_VERSION_MIDDLE} -gt 121 ];
569 elif [ ${JACK_VERSION_MAJOR} -gt 0 ];
573 elif [ "jackdmp" = ${JACK_NAME} ];
575 if [ ${JACK_VERSION_MAJOR} -eq 1 ];
577 if [ ${JACK_VERSION_MIDDLE} -eq 9 ];
579 if [ ${JACK_VERSION_MINOR} -ge 8 ];
583 elif [ ${JACK_VERSION_MIDDLE} -gt 9 ];
587 elif [ ${JACK_VERSION_MAJOR} -gt 1 ];
593 if [ "t" = ${JACK_VERSION_OK} ];
596 echo "Jack Version Check OK (${JACK_VER_STRING})"
600 echo "!!! WARNING !!! - The version of Jack on this system is too old!"
601 echo "Using an old version of Jack is not recommended. Please update"
602 echo "Jack for best results."
604 echo "System Jack version:"
605 echo " ${JACK_VER_STRING}"
607 echo "Recommended minimum versions:"
608 echo " Jack1 - 0.121.3"
609 echo " Jack2 - 1.9.8"
611 read -p "Press ENTER to continue:" BLAH
615 if ! which qjackctl > /dev/null;
618 echo "The program QjackCtl is missing from this system."
619 echo "QjackCtl is an extremely useful tool for any system that runs JACK applications like $PGM_NAME."
620 echo "We recommend that you install it."
623 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
625 if test "y" = $ANSWER;
627 echo "Attempting to install QjackCtl"
628 SystemInstall "qjackctl"
633 read -p "Press ENTER to continue:" BLAH
639 ########################
641 ########################
643 USER_GROUP_ADJUSTED="f"
645 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -a > /dev/null";
648 echo "System failed the quick sanity check... Looking for the cause"
650 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -rt > /dev/null";
653 echo "System does not allow realtime for the current user... Looking for a solution"
655 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasaudiogroup > /dev/null";
657 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1";
659 ## This is an odd case. We have an audio group and are a member.
661 echo "!!! WARNING !!! - The current user can not execute realtime processes."
662 echo "This will adversely affect audio latency."
663 echo "This system has an audio group and the user is a member. If jack was"
664 echo "just installed, a simple log out/in may fix this."
666 echo "For best results, please correct this on your system."
667 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
669 read -p "Press ENTER to continue:" BLAH
671 # Not a member of an audio group. Try to fix it.
673 if ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasgroup audio > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@audio.*rtprio" ";
675 # add user to audio group
677 echo "Adding user ${USER_NAME} to the audio group."
678 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
680 read -p "Press ENTER to continue:" BLAH
682 if ${SUPER} usermod -a -G audio ${USER_NAME};
684 USER_GROUP_ADJUSTED="t"
687 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
689 echo "Please add yourself to the audio group and re-login"
691 read -p "Press ENTER to continue:" BLAH
694 elif ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -hasgroup jackuser > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@jackuser.*rtprio" ";
696 # add user to jackuser group
698 echo "Adding user ${USER_NAME} to the jackuser group."
699 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
701 read -p "Press ENTER to continue:" BLAH
703 if ${SUPER} usermod -a -G jackuser ${USER_NAME};
705 USER_GROUP_ADJUSTED="t"
708 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
710 echo "Please add yourself to the audio group and re-login"
712 read -p "Press ENTER to continue:" BLAH
719 # No audio group found on this system!
721 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
723 echo "We will not attempt to fix this. Please configure your system to allow"
724 echo "non-root users to execute realtime tasks."
726 read -p "Press ENTER to continue:" BLAH
730 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -freqscaling > /dev/null";
733 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
734 echo "This can have a serious impact on audio latency."
735 echo "For best results turn it off, e.g. by chosing the 'performance' governor."
737 read -p "Press ENTER to continue:" BLAH
740 if [ "f" = $USER_GROUP_ADJUSTED ];
742 if ! ${NORM_USER} "${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/sanityCheck -memlock > /dev/null";
745 echo "!!! WARNING !!! - You are not allowed to lock memory."
747 echo "We will not attempt to fix this. Please configure your system to allow"
748 echo "non-root users to execute lock memory."
750 read -p "Press ENTER to continue:" BLAH
756 ########################
758 ########################
762 rm -rf ${BUNDLE_DIR}/
765 echo "!!! Install Complete !!!"
767 if [ "t" = $USER_GROUP_ADJUSTED ];
769 echo "You will need to logout and then login again for all changes to be complete"
773 read -p "Press ENTER to exit installer:" BLAH