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 ########################################################################
103 echo "Welcome to the ${PGM_NAME} installer"
115 echo "Either you don't know the root password or the user is not allowed to sudo"
116 echo "Please correct this and run the installer again (hint: use visudo to edit sudoers file)"
118 read -p "Press ENTER to exit installer:" BLAH
122 ############################
123 # Determine processor type
124 ############################
127 i[3456789]86|x86|i86pc)
128 echo "Architecture is x86"
132 echo "Architecture is x86_64"
137 echo "!!! ERROR !!! - Unknown architecture `uname -m`"
139 read -p "Press ENTER to exit installer:" BLAH
144 # untar the correct bundle for us to install
145 echo "Unpacking bundle for $ARCH"
146 tar -xjf ${PGM_NAME}_${ARCH}-*.tar.bz2
147 BUNDLE_DIR=$(basename `find -maxdepth 1 -type d -name "${PGM_NAME}_${ARCH}-*"`)
150 #######################
151 # Check for xdg utils
152 #######################
154 XDG_MENU_VER=$(xdg-desktop-menu --version 2> /dev/null)
155 if [ -z "$XDG_MENU_VER" ];
157 echo "System does not have xdg-desktop-menu installed"
161 XDG_ICON_VER=$(xdg-icon-resource --version 2> /dev/null)
162 if [ -z "$XDG_ICON_VER" ];
164 echo "System does not have xdg-icon-resource installed"
168 #################################################
169 # Check if system libs are OK (libc, etc)
170 #################################################
173 echo "Checking system libs to see if they are compatible with ${PGM_NAME}."
177 LD_PATH=`pwd`/${BUNDLE_DIR}/lib
180 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd ${BUNDLE_DIR}/bin/${PGM_NAME_LOWER}-* 2>&1 > /dev/null)
182 if [ -n "$LDD_RESULT" ];
189 LIB_FILES=$(find ${BUNDLE_DIR}/lib -name "*.so")
191 for path in $LIB_FILES
193 LDD_RESULT=$(LD_LIBRARY_PATH=${LD_PATH} ldd $path 2>&1 > /dev/null)
194 if [ -n "$LDD_RESULT" ];
201 if test "T" = $LIB_ERROR;
204 echo "!!! ERROR !!! - Missing library detected!"
205 echo "This system does not have the correct libs to run ${PGM_NAME}."
206 echo "Installation will not complete. Please use a compatible distro."
208 read -p "Press ENTER to exit installer:" BLAH
212 ################################
213 # Setup derived variables
214 ################################
215 PGM_VERSION=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $1}')
216 PGM_BUILD=$(echo ${BUNDLE_DIR} | awk 'BEGIN { FS = "-" } ; { print $2 }' | awk 'BEGIN { FS = "_"} ; { print $2}')
217 PGM_FULL_NAME="${PGM_NAME}-${PGM_VERSION}_${PGM_BUILD}"
219 ICON_NAME="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}" #no dash since it seperates vendor from program
220 MENU_FILE="${PGM_VENDOR}-${PGM_NAME}_${PGM_VERSION}.desktop" #no dash since it seperates vendor from program
221 DESKTOP_LINK_FILE="${PGM_NAME}_${PGM_VERSION}.desktop"
223 PGM_EXEC_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/bin/${PGM_EXEC_FILE}"
224 ICON_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/etc/icons"
225 MENU_FILE_PATH="${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/share"
229 ################################
230 # Install bundle and Menu/Link
231 ################################
233 if [ ! -d ${INSTALL_DEST_BASE} ];
236 echo "!!! ERROR !!! - Installation location ${INSTALL_DEST_BASE} does not exist!"
237 echo "Installation will not complete."
239 read -p "Press ENTER to exit installer:" BLAH
243 # uninstall any older versions
244 UNINSTALLERS=$(find ${INSTALL_DEST_BASE} -maxdepth 1 -type f -name "${PGM_NAME}*.uninstall.sh")
245 if [ ! -z "$UNINSTALLERS" ];
247 for i in $UNINSTALLERS; do
249 echo "Found existing ${PGM_NAME} installation."
251 ANSWER=$(VaildateYesNoQuestion "Do you want to run the uninstaller ${i} ?")
253 if test "y" = $ANSWER;
256 echo "Running uninstaller $i"
267 echo "Installing ${PGM_NAME} ${PGM_VERSION} built from ${PGM_BUILD} in ${INSTALL_DEST_BASE}"
270 # Copy the new version in the install directory
271 sudo mkdir ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}
272 sudo cp -Rf ${BUNDLE_DIR}/* ${INSTALL_DEST_BASE}/${PGM_FULL_NAME}/
274 # write the desktop/menu file
275 echo "[Desktop Entry]" > /tmp/${MENU_FILE}
276 echo "Encoding=UTF-8" >> /tmp/${MENU_FILE}
277 echo "Version=1.0" >> /tmp/${MENU_FILE}
278 echo "Type=Application" >> /tmp/${MENU_FILE}
279 echo "Terminal=false" >> /tmp/${MENU_FILE}
280 echo "Exec=${PGM_EXEC_PATH}" >> /tmp/${MENU_FILE}
281 echo "Name=${PGM_NAME}-${PGM_VERSION}" >> /tmp/${MENU_FILE}
282 echo "Icon=${ICON_NAME}" >> /tmp/${MENU_FILE}
283 echo "Comment=Digital Audio Workstation" >> /tmp/${MENU_FILE}
284 echo "Categories=AudioVideo;Audio;Recorder;" >> /tmp/${MENU_FILE}
286 chmod ugo+rx /tmp/${MENU_FILE}
287 sudo mv /tmp/${MENU_FILE} ${MENU_FILE_PATH}/.
289 # install the Menu, Link, and Icon(s)
290 if [ "T" = ${HAS_XDG} ];
292 echo "Adding ${PGM_NAME} to the applications menu"
293 sudo xdg-icon-resource install --context apps --size 16 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_16px.png ${ICON_NAME}
294 sudo xdg-icon-resource install --context apps --size 22 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_22px.png ${ICON_NAME}
295 sudo xdg-icon-resource install --context apps --size 32 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_32px.png ${ICON_NAME}
296 sudo xdg-icon-resource install --context apps --size 48 ${ICON_PATH}/${PGM_NAME_LOWER}_icon_48px.png ${ICON_NAME}
298 if [ -e ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg -a -d /usr/share/icons/hicolor/scalable/apps ];
300 sudo cp -f ${ICON_PATH}/${PGM_NAME_LOWER}_icon.svg /usr/share/icons/hicolor/scalable/apps/${ICON_NAME}.svg
303 sudo xdg-desktop-menu install ${MENU_FILE_PATH}/${MENU_FILE}
306 echo "Creating a desktop link for ${PGM_NAME}"
307 cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
308 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
311 echo "Creating a desktop link for ${PGM_NAME}"
312 cp ${MENU_FILE_PATH}/${MENU_FILE} ~/Desktop/${DESKTOP_LINK_FILE}
313 chmod ugo+rx ~/Desktop/${DESKTOP_LINK_FILE}
317 echo "Copying uninstall script to ${INSTALL_DEST_BASE}"
320 sudo cp -f ${BUNDLE_DIR}/bin/*.uninstall.sh ${INSTALL_DEST_BASE}/.
322 ###########################
323 # Check Jack and qjackctl
324 ###########################
327 echo "Checking to see if Jack is installed"
330 if ! which jackd > /dev/null;
333 echo "The program Jack is missing from this system. Jack is a required component of $PGM_NAME."
336 ANSWER=$(VaildateYesNoQuestion "Install jack using system software repository?")
338 if test "y" = $ANSWER;
340 echo "Attempting to install Jack"
341 SystemInstall "jackd"
346 read -p "Press ENTER to continue:" BLAH
354 if ! which qjackctl > /dev/null;
357 echo "The program QjackCtl is missing from this system. QjackCtl is an extremely useful tool"
358 echo "for any system that runs JACK applications like Ardour. We recommend that you install it."
361 ANSWER=$(VaildateYesNoQuestion "Install QjackCtl using system software repository?")
363 if test "y" = $ANSWER;
365 echo "Attempting to install QjackCtl"
366 SystemInstall "qjackctl"
371 read -p "Press ENTER to continue:" BLAH
377 ########################
379 ########################
381 USER_GROUP_ADJUSTED="f"
383 if ! ./${BUNDLE_DIR}/bin/sanityCheck -a > /dev/null;
386 echo "System failed the quick sanity check... Looking for the cause"
388 if ! ./${BUNDLE_DIR}/bin/sanityCheck -rt > /dev/null;
391 echo "System does not allow realtime for the current user... Looking for a solution"
393 if ./${BUNDLE_DIR}/bin/sanityCheck -hasaudiogroup > /dev/null;
395 if ./${BUNDLE_DIR}/bin/sanityCheck -memberaudiogroup > /dev/null 2>&1;
397 ## This is an odd case. We have an audio group and are a member.
399 echo "!!! WARNING !!! - The current user can not execute realtime processes."
400 echo "This will adversely affect audio latency."
401 echo "This system has an audio group and the user is a member. If jack was"
402 echo "just installed, a simple log out/in may fix this."
404 echo "For best results, please correct this on your system."
405 echo "(Hint: check /etc/security/limits.conf or /etc/security/limits.d/)"
407 read -p "Press ENTER to continue:" BLAH
409 # Not a member of an audio group. Try to fix it.
411 if ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup audio > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@audio.*rtprio";
413 # add user to audio group
415 echo "Adding user `whoami` to the audio group."
416 echo "This should allow you to run realtime tasks. Please re-login for this change to take affect."
418 read -p "Press ENTER to continue:" BLAH
421 if sudo usermod -a -G audio $user;
423 USER_GROUP_ADJUSTED="t"
426 echo "!!! ERROR !!! - Not able to add user to the audio group (usermod failed)!"
428 echo "Please add yourself to the audio group and re-login"
430 read -p "Press ENTER to continue:" BLAH
433 elif ./${BUNDLE_DIR}/bin/sanityCheck -hasgroup jackuser > /dev/null && find /etc/security -type f -name "*.conf" | xargs grep -q "^@jackuser.*rtprio";
435 # add user to jackuser group
437 echo "Adding user `whoami` to the jackuser 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 jackuser $user;
445 USER_GROUP_ADJUSTED="t"
448 echo "!!! ERROR !!! - Not able to add user to the jackuser group."
450 echo "Please add yourself to the audio group and re-login"
452 read -p "Press ENTER to continue:" BLAH
459 # No audio group found on this system!
461 echo "!!! WARNING !!! - The system does not seem to have an audio group (audio or jackuser)."
463 echo "We will not attempt to fix this. Please configure your system to allow"
464 echo "non-root users to execute realtime tasks."
466 read -p "Press ENTER to continue:" BLAH
470 if ! ./${BUNDLE_DIR}/bin/sanityCheck -freqscaling > /dev/null;
473 echo "!!! WARNING !!! - Your system seems to use frequency scaling."
474 echo "This can have a serious impact on audio latency. You have two choices:"
475 echo "(1) turn it off, e.g. by chosing the 'performance' governor."
476 echo "(2) Use the HPET clocksource by passing \"-c h\" to JACK"
477 echo "(this second option only works on relatively recent computers)"
479 read -p "Press ENTER to continue:" BLAH
482 if [ "f" = $USER_GROUP_ADJUSTED ];
484 if ! ./${BUNDLE_DIR}/bin/sanityCheck -memlock > /dev/null;
487 echo "!!! WARNING !!! - You are not allowed to lock memory."
489 echo "We will not attempt to fix this. Please configure your system to allow"
490 echo "non-root users to execute lock memory."
492 read -p "Press ENTER to continue:" BLAH
498 ########################
500 ########################
504 rm -rf ${BUNDLE_DIR}/
507 echo "!!! Install Complete !!!"
509 if [ "t" = $USER_GROUP_ADJUSTED ];
511 echo "You will need to logout and then login again for all changes to be complete"
515 read -p "Press ENTER to close this window:" BLAH