3 ####################################
6 # Ardour/Mixbus bundle installer
9 ###################################
15 PGM_EXEC_FILE="ardour3"
17 INSTALL_DEST_BASE="/opt"
19 PGM_NAME_LOWER=$(echo $PGM_NAME | tr '[:upper:]' '[:lower:]')
21 #### Global Variables ####
24 ########################
25 # Function Definitions
26 ########################
28 VaildateYesNoQuestion ()
35 until test "y" = $INPUT_OK;
38 read -p "$1 [y/n]: " USER_INPUT
41 if [ ! -z $USER_INPUT ];
43 if [ "Y" = $USER_INPUT -o "y" = $USER_INPUT -o "n" = $USER_INPUT -o "N" = $USER_INPUT ];
50 echo $USER_INPUT | tr '[:upper:]' '[:lower:]'
57 # Determine which software install app to use and then install requested package
60 if which yum > /dev/null;
62 ${SUPER} yum -y install $1
68 echo "!!! ERROR !!! yum install failed for an unknown reason."
69 echo "Please install package $1 after this installer completes."
73 elif which apt-get > /dev/null;
75 ${SUPER} apt-get -y install $1
81 echo "!!! ERROR !!! apt-get install failed for an unknown reason."
82 echo "Please install package $1 after this installer completes."
88 echo "!!! ERROR !!! - Not able to detect which software install tool to use (yum or apt-get)."
89 echo "Please install package $1 using the system software install tool."
98 ########################################################################
100 ########################################################################
102 # If you double click a script, some systems don't get the PWD correct.
103 # Force it to be correct
104 PKG_PATH=$(dirname $(readlink -f $0))
108 echo "Welcome to the ${PGM_NAME} installer"
111 #############################
112 # Check for root privileges
113 #############################
117 if [ "$(id -u)" != "0" ]; then
119 if ! which sudo > /dev/null;
124 echo "The installer requires root privileges. It is currently not"
125 echo "running as root AND the program sudo is missing from this system."
127 echo "Please correct this by installing and configuring sudo or running"
128 echo "the installer as root."
130 read -p "Press ENTER to exit installer:" BLAH
139 echo "Either you don't know the root password or the user is not allowed to sudo"
140 echo "Please correct this and run the installer again"
141 echo "(hint: use visudo to edit sudoers file)"
143 read -p "Press ENTER to exit installer:" BLAH
149 echo "!!! Warning !!!"
151 echo "The installer is running as the root user which is not the prefered method."
152 echo "There are checks run at the end of the installer to help ensure proper operation"
153 echo "of ${PGM_NAME} (realtime priviledges, memory locking, frequency scaling)."
154 echo "Running as root will invalidate these tests."
156 read -p "Press ENTER to continue:" BLAH
160 ############################
161 # Determine processor type
162 ############################
165 i[3456789]86|x86|i86pc)
166 echo "Architecture is x86"
170 echo "Architecture is x86_64"
175 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
177 read -p "Press ENTER to exit installer:" BLAH
186 # We have to check the current folder and the INSTALL_DEST_BASE just
187 # in case they are on different devices
188 echo "Checking for required disk space"
190 if [ ! -e .${PGM_NAME}_${ARCH}-*.size ]; then
192 echo "!!! ERROR !!! Can't locate .size file for ${ARCH} bundle."
196 REQUIRED_BYTES=$(cat .${PGM_NAME}_${ARCH}-*.size)
198 #Check space in current folder
199 FREE_BYTES=$(df -P -B 1 ${PKG_PATH} | grep / | awk '{print $4}')
201 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
203 echo "!!! ERROR !!! - Insufficient disk space in ${PKG_PATH}"
208 #Check space in INSTALL_DEST_BASE
209 FREE_BYTES=$(df -P -B 1 ${INSTALL_DEST_BASE} | grep / | awk '{print $4}')
211 if [ ${FREE_BYTES} -le ${REQUIRED_BYTES} ] ; then
213 echo "!!! ERROR !!! - Insufficient disk space in ${INSTALL_DEST_BASE}"
219 #####################
221 #####################
223 # untar the correct bundle for us to install
224 echo "Unpacking bundle for $ARCH"
226 if [ ! -e ${PGM_NAME}_${ARCH}-*.tar.bz2 ]; then
228 echo "!!! ERROR !!! Can't locate ${ARCH} bundle file."
233 tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
234 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
237 #######################
238 # Check for xdg utils
239 #######################
241 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
242 if [ -z "$XDG_MENU_VER" ];
244 echo "System does not have xdg-desktop-menu installed"
248 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
249 if [ -z "$XDG_ICON_VER" ];
251 echo "System does not have xdg-icon-resource installed"
255 #################################################
256 # Check if system libs are OK (libc, etc)
257 #################################################
260 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
264 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
267 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
269 if [ -n "$LDD_RESULT" ];
276 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
278 for path in $LIB_FILES
280 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
281 if [ -n "$LDD_RESULT" ];
288 if test "T" = $LIB_ERROR;
291 echo "!!! ERROR !!! - Missing library detected!"
292 echo "This system does not have the correct libs to run ${PGM_NAME}."
293 echo "Installation will not complete. Please use a compatible distro."
295 read -p "Press ENTER to exit installer:" BLAH
299 ################################
300 # Setup derived variables
301 ################################
302 PGM_VERSION=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $1}')
303 PGM_BUILD=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $2}')
304 PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $3 }')
306 if [ -z ${PGM_BUILDTYPE} ];
308 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}"
309 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}" #no dash between name and version since dash seperates vendor from program
310 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop" #no dash between name and version since dash seperates vendor from program
311 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
313 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}-${PGM_BUILDTYPE}"
314 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}" #no dash between name and version since dash seperates vendor from program
315 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop" #no dash between name and version since dash seperates vendor from program
316 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"
319 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
320 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/etc/icons"
321 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
325 ################################
326 # Install bundle and Menu/Link
327 ################################
329 if [ ! -d ${INSTALL_DEST_BASE} ];
332 echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
333 echo "Installation will not complete."
335 read -p "Press ENTER to exit installer:" BLAH
339 # uninstall any older versions
340 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
341 if [ ! -z "$UNINSTALLERS" ];
343 for i in $UNINSTALLERS; do
345 echo "Found existing ${PGM_NAME} installation."
347 ANSWER=$(VaildateYesNoQuestion "Do you want to run the uninstaller ${i} ?")
349 if test "y" = $ANSWER;
352 echo "Running uninstaller $i"
364 echo "Installing ${PGM_NAME} ${PGM_VERSION} built from ${PGM_BUILD} in ${INSTALL_DEST_BASE}"
367 # Copy the new version in the install directory
368 ${SUPER} mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
369 ${SUPER} cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
371 # write the desktop/menu file
372 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
373 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
374 echo "Version=1.0" >> /tmp/${MENU_FILE}
375 echo "Type=Application" >> /tmp/${MENU_FILE}
376 echo "Terminal=false" >> /tmp/${MENU_FILE}
377 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
378 if [ -z ${PGM_BUILDTYPE} ];
380 echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
382 echo "Name=${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}" >> /tmp/${MENU_FILE}
384 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
385 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
386 echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
388 chmod ugo+rx /tmp/${MENU_FILE}
389 ${SUPER} mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
391 # install the Menu, Link, and Icon(s)
392 if [ "T" = ${HAS_XDG} ];
394 echo "Adding ${PGM_NAME} to the applications menu"
395 ${SUPER} xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
396 ${SUPER} xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
397 ${SUPER} xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
398 ${SUPER} xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
400 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
402 ${SUPER} cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
405 ${SUPER} xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
406 ${SUPER} xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
409 echo "Creating a desktop link for ${PGM_NAME}"
410 cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
411 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
414 echo "Creating a desktop link for ${PGM_NAME}"
415 cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
416 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
420 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
423 ${SUPER} cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
425 ###########################
426 # Check Jack and qjackctl
427 ###########################
430 echo "Checking to see if Jack is installed"
433 if ! which jackd > /dev/null;
436 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
439 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
441 if test "y" = $ANSWER;
443 echo "Attempting to install Jack"
444 SystemInstall "jackd"
449 read -p "Press ENTER to continue:" BLAH
457 if ! which qjackctl > /dev/null;
460 echo "The program QjackCtl is missing from this system."
461 echo "QjackCtl is an extremely useful tool for any system that runs JACK applications like $PGM_NAME."
462 echo "We recommend that you install it."
465 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
467 if test "y" = $ANSWER;
469 echo "Attempting to install QjackCtl"
470 SystemInstall "qjackctl"
475 read -p "Press ENTER to continue:" BLAH
481 ########################
483 ########################
485 USER_GROUP_ADJUSTED="f"
487 if ! ./${BUNDLE_DIR}/bin/sanityCheck -a > /dev/null;
490 echo "System failed the quick sanity check... Looking for the cause"
492 if ! ./${BUNDLE_DIR}/bin/sanityCheck -rt > /dev/null;
495 echo "System does not allow realtime for the current user... Looking for a solution"
497 if ./${BUNDLE_DIR}/bin/sanityCheck -hasaudiogroup > /dev/null;
499 if ./${BUNDLE_DIR}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1;
501 ## This is an odd case. We have an audio group and are a member.
503 echo "!!! WARNING !!! - The current user can not execute realtime processes."
504 echo "This will adversely affect audio latency."
505 echo "This system has an audio group and the user is a member. If jack was"
506 echo "just installed, a simple log out/in may fix this."
508 echo "For best results, please correct this on your system."
509 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
511 read -p "Press ENTER to continue:" BLAH
513 # Not a member of an audio group. Try to fix it.
515 if ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup audio > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@audio.*rtprio";
517 # add user to audio group
519 echo "Adding user `whoami` to the audio group."
520 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
522 read -p "Press ENTER to continue:" BLAH
525 if ${SUPER} usermod -a -G audio $user;
527 USER_GROUP_ADJUSTED="t"
530 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
532 echo "Please add yourself to the audio group and re-login"
534 read -p "Press ENTER to continue:" BLAH
537 elif ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup jackuser > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@jackuser.*rtprio";
539 # add user to jackuser group
541 echo "Adding user `whoami` to the jackuser group."
542 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
544 read -p "Press ENTER to continue:" BLAH
547 if ${SUPER} usermod -a -G jackuser $user;
549 USER_GROUP_ADJUSTED="t"
552 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
554 echo "Please add yourself to the audio group and re-login"
556 read -p "Press ENTER to continue:" BLAH
563 # No audio group found on this system!
565 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
567 echo "We will not attempt to fix this. Please configure your system to allow"
568 echo "non-root users to execute realtime tasks."
570 read -p "Press ENTER to continue:" BLAH
574 if ! ./${BUNDLE_DIR}/bin/sanityCheck -freqscaling > /dev/null;
577 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
578 echo "This can have a serious impact on audio latency. You have two choices:"
579 echo "(1) turn it off, e.g. by chosing the 'performance' governor."
580 echo "(2) Use the HPET clocksource by passing \"-c h\" to JACK"
581 echo "(this second option only works on relatively recent computers)"
583 read -p "Press ENTER to continue:" BLAH
586 if [ "f" = $USER_GROUP_ADJUSTED ];
588 if ! ./${BUNDLE_DIR}/bin/sanityCheck -memlock > /dev/null;
591 echo "!!! WARNING !!! - You are not allowed to lock memory."
593 echo "We will not attempt to fix this. Please configure your system to allow"
594 echo "non-root users to execute lock memory."
596 read -p "Press ENTER to continue:" BLAH
602 ########################
604 ########################
608 rm -rf ${BUNDLE_DIR}/
611 echo "!!! Install Complete !!!"
613 if [ "t" = $USER_GROUP_ADJUSTED ];
615 echo "You will need to logout and then login again for all changes to be complete"
619 read -p "Press ENTER to exit installer:" BLAH