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 sudo 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 sudo 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"
120 echo "Either you don't know the root password or the user is not allowed to sudo"
121 echo "Please correct this and run the installer again (hint: use visudo to edit sudoers file)"
123 read -p "Press ENTER to exit installer:" BLAH
127 ############################
128 # Determine processor type
129 ############################
132 i[3456789]86|x86|i86pc)
133 echo "Architecture is x86"
137 echo "Architecture is x86_64"
142 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
144 read -p "Press ENTER to exit installer:" BLAH
149 # untar the correct bundle for us to install
150 echo "Unpacking bundle for $ARCH"
151 tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
152 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
155 #######################
156 # Check for xdg utils
157 #######################
159 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
160 if [ -z "$XDG_MENU_VER" ];
162 echo "System does not have xdg-desktop-menu installed"
166 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
167 if [ -z "$XDG_ICON_VER" ];
169 echo "System does not have xdg-icon-resource installed"
173 #################################################
174 # Check if system libs are OK (libc, etc)
175 #################################################
178 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
182 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
185 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
187 if [ -n "$LDD_RESULT" ];
194 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
196 for path in $LIB_FILES
198 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
199 if [ -n "$LDD_RESULT" ];
206 if test "T" = $LIB_ERROR;
209 echo "!!! ERROR !!! - Missing library detected!"
210 echo "This system does not have the correct libs to run ${PGM_NAME}."
211 echo "Installation will not complete. Please use a compatible distro."
213 read -p "Press ENTER to exit installer:" BLAH
217 ################################
218 # Setup derived variables
219 ################################
220 PGM_VERSION=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $1}')
221 PGM_BUILD=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $2}')
222 PGM_BUILDTYPE=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $3 }')
224 if [ -z ${PGM_BUILDTYPE} ];
226 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}"
227 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}" #no dash between name and version since dash seperates vendor from program
228 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop" #no dash between name and version since dash seperates vendor from program
229 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
231 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}-${PGM_BUILDTYPE}"
232 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}" #no dash between name and version since dash seperates vendor from program
233 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop" #no dash between name and version since dash seperates vendor from program
234 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}_${PGM_BUILDTYPE}.desktop"
237 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
238 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/etc/icons"
239 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
243 ################################
244 # Install bundle and Menu/Link
245 ################################
247 if [ ! -d ${INSTALL_DEST_BASE} ];
250 echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
251 echo "Installation will not complete."
253 read -p "Press ENTER to exit installer:" BLAH
257 # uninstall any older versions
258 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
259 if [ ! -z "$UNINSTALLERS" ];
261 for i in $UNINSTALLERS; do
263 echo "Found existing ${PGM_NAME} installation."
265 ANSWER=$(VaildateYesNoQuestion "Do you want to run the uninstaller ${i} ?")
267 if test "y" = $ANSWER;
270 echo "Running uninstaller $i"
282 echo "Installing ${PGM_NAME} ${PGM_VERSION} built from ${PGM_BUILD} in ${INSTALL_DEST_BASE}"
285 # Copy the new version in the install directory
286 sudo mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
287 sudo cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
289 # write the desktop/menu file
290 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
291 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
292 echo "Version=1.0" >> /tmp/${MENU_FILE}
293 echo "Type=Application" >> /tmp/${MENU_FILE}
294 echo "Terminal=false" >> /tmp/${MENU_FILE}
295 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
296 if [ -z ${PGM_BUILDTYPE} ];
298 echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
300 echo "Name=${PGM_NAME}-${PGM_VERSION}-${PGM_BUILDTYPE}" >> /tmp/${MENU_FILE}
302 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
303 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
304 echo "Categories=AudioVideo;AudioEditing;Audio;Recorder;" >> /tmp/${MENU_FILE}
306 chmod ugo+rx /tmp/${MENU_FILE}
307 sudo mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
309 # install the Menu, Link, and Icon(s)
310 if [ "T" = ${HAS_XDG} ];
312 echo "Adding ${PGM_NAME} to the applications menu"
313 sudo xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
314 sudo xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
315 sudo xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
316 sudo xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
318 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
320 sudo cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
323 sudo xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
324 sudo xdg-desktop-menu forceupdate --mode system # Some systems need an extra kick
327 echo "Creating a desktop link for ${PGM_NAME}"
328 cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
329 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
332 echo "Creating a desktop link for ${PGM_NAME}"
333 cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
334 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
338 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
341 sudo cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
343 ###########################
344 # Check Jack and qjackctl
345 ###########################
348 echo "Checking to see if Jack is installed"
351 if ! which jackd > /dev/null;
354 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
357 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
359 if test "y" = $ANSWER;
361 echo "Attempting to install Jack"
362 SystemInstall "jackd"
367 read -p "Press ENTER to continue:" BLAH
375 if ! which qjackctl > /dev/null;
378 echo "The program QjackCtl is missing from this system."
379 echo "QjackCtl is an extremely useful tool for any system that runs JACK applications like $PGM_NAME."
380 echo "We recommend that you install it."
383 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
385 if test "y" = $ANSWER;
387 echo "Attempting to install QjackCtl"
388 SystemInstall "qjackctl"
393 read -p "Press ENTER to continue:" BLAH
399 ########################
401 ########################
403 USER_GROUP_ADJUSTED="f"
405 if ! ./${BUNDLE_DIR}/bin/sanityCheck -a > /dev/null;
408 echo "System failed the quick sanity check... Looking for the cause"
410 if ! ./${BUNDLE_DIR}/bin/sanityCheck -rt > /dev/null;
413 echo "System does not allow realtime for the current user... Looking for a solution"
415 if ./${BUNDLE_DIR}/bin/sanityCheck -hasaudiogroup > /dev/null;
417 if ./${BUNDLE_DIR}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1;
419 ## This is an odd case. We have an audio group and are a member.
421 echo "!!! WARNING !!! - The current user can not execute realtime processes."
422 echo "This will adversely affect audio latency."
423 echo "This system has an audio group and the user is a member. If jack was"
424 echo "just installed, a simple log out/in may fix this."
426 echo "For best results, please correct this on your system."
427 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
429 read -p "Press ENTER to continue:" BLAH
431 # Not a member of an audio group. Try to fix it.
433 if ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup audio > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@audio.*rtprio";
435 # add user to audio group
437 echo "Adding user `whoami` to the audio group."
438 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
440 read -p "Press ENTER to continue:" BLAH
443 if sudo usermod -a -G audio $user;
445 USER_GROUP_ADJUSTED="t"
448 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
450 echo "Please add yourself to the audio group and re-login"
452 read -p "Press ENTER to continue:" BLAH
455 elif ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup jackuser > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@jackuser.*rtprio";
457 # add user to jackuser group
459 echo "Adding user `whoami` to the jackuser group."
460 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
462 read -p "Press ENTER to continue:" BLAH
465 if sudo usermod -a -G jackuser $user;
467 USER_GROUP_ADJUSTED="t"
470 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
472 echo "Please add yourself to the audio group and re-login"
474 read -p "Press ENTER to continue:" BLAH
481 # No audio group found on this system!
483 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
485 echo "We will not attempt to fix this. Please configure your system to allow"
486 echo "non-root users to execute realtime tasks."
488 read -p "Press ENTER to continue:" BLAH
492 if ! ./${BUNDLE_DIR}/bin/sanityCheck -freqscaling > /dev/null;
495 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
496 echo "This can have a serious impact on audio latency. You have two choices:"
497 echo "(1) turn it off, e.g. by chosing the 'performance' governor."
498 echo "(2) Use the HPET clocksource by passing \"-c h\" to JACK"
499 echo "(this second option only works on relatively recent computers)"
501 read -p "Press ENTER to continue:" BLAH
504 if [ "f" = $USER_GROUP_ADJUSTED ];
506 if ! ./${BUNDLE_DIR}/bin/sanityCheck -memlock > /dev/null;
509 echo "!!! WARNING !!! - You are not allowed to lock memory."
511 echo "We will not attempt to fix this. Please configure your system to allow"
512 echo "non-root users to execute lock memory."
514 read -p "Press ENTER to continue:" BLAH
520 ########################
522 ########################
526 rm -rf ${BUNDLE_DIR}/
529 echo "!!! Install Complete !!!"
531 if [ "t" = $USER_GROUP_ADJUSTED ];
533 echo "You will need to logout and then login again for all changes to be complete"
537 read -p "Press ENTER to exit installer:" BLAH