From eecd65119c002eed27c1075146ae7636f4fa5ebd Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Fri, 27 Jul 2012 16:59:22 -0500 Subject: Allow migratekde3 script to continue automatically when sufficient disk space exists. Improve messages and add more error trapping in r14-xdg-update script. --- migratekde3 | 8 ++- r14-xdg-update | 161 +++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 105 insertions(+), 64 deletions(-) diff --git a/migratekde3 b/migratekde3 index 7e5969def..62f679326 100644 --- a/migratekde3 +++ b/migratekde3 @@ -80,11 +80,15 @@ echo "Space required for new profile: ${PROFILE_SIZE} MB" # If obvious insufficient space then inform and quit. if [ $PROFILE_SIZE -gt $REMAINING_SPACE ]; then echo "Insufficient disk space. Exiting." + echo exit 0 +else + echo "Sufficient disk space exists. Continuing." + echo fi # Ask whether to proceed. -Wait_For_Response "Migrate?" -Proceed_From_Response +# Wait_For_Response "Migrate?" +# Proceed_From_Response # User wants to migrate. echo "Migrating an existing KDE3 profile directory:" 1>&2 echo "This is a one-time event." 1>&2 diff --git a/r14-xdg-update b/r14-xdg-update index 54ceddf7f..8e0c03fab 100644 --- a/r14-xdg-update +++ b/r14-xdg-update @@ -69,12 +69,12 @@ SCRIPT_NAME="`basename \`readlink -f $0\``" unset KDEGLOBALS_KEY_VALUE -WARNING_MESSAGE="Trinity R14 XDG compliance updates will not be performed.\n\nWithout R14 XDG compliance updates, some Trinity apps will fail to\nfunction properly.\n\nFailures include the following:\n\n* Many left-side icon lists will not populate,\n such as the Panel and Konqueror configuration dialogs.\n\n* User-defined keyboard shortcuts fail (khotkeysrc).\n System defined shortcuts remain functional.\n\n* User-defined app preferences fail (profilerc).\n\n* Konqueror navigation/sidebar panel won't open.\n\n* User-defined konqueror service menus, kicker customization,\n konqueror sidebar, Recent Documents list fail.\n\nPossible remedies:\n\n* If necessary contact your system administrator." +WARNING_MESSAGE="Trinity R14 XDG compliance updates will not be performed automatically.\n\nWithout R14 XDG compliance updates, some Trinity apps will fail to\nfunction properly.\n\nFailures include the following:\n\n* Many left-side icon lists will not populate,\n such as the Panel and Konqueror configuration dialogs.\n\n* User-defined keyboard shortcuts fail (khotkeysrc).\n System defined shortcuts remain functional.\n\n* User-defined app preferences fail (profilerc).\n\n* Konqueror navigation/sidebar panel won't open.\n\n* User-defined konqueror service menus, kicker customization,\n konqueror sidebar, Recent Documents list fail.\n\nPlease take appropriate action.\n" # As the user should not be logged into a Trinity session when running # this script, or an administrator might run this script remotely, the -# $TDEHOME variable probably is not set or knowable from within this script. -# We presume $HOME/.trinity, but provide a way to pass an environment +# $TDEHOME variable might not be set or knowable from within this script. +# We presume $HOME/.trinity and provide a way to pass an environment # variable to change that location. if [ "$TDEHOME" = "" ]; then PROFILE_DIR=${PROFILE_DIR:-"$HOME/.trinity"} @@ -82,19 +82,19 @@ else PROFILE_DIR="$TDEHOME" fi if [ ! -d "$PROFILE_DIR" ]; then - MESSAGE="Unable to determine the user profile directory.\n\n${WARNING_MESSAGE}" + MESSAGE="Warning! Unable to find the user profile directory $PROFILE_DIR.\n\n${WARNING_MESSAGE}" # Are we in X? Display an X dialog explaining breakage. if [ "$DISPLAY" != "" ]; then echo -e "$MESSAGE" | xmessage -center -file - -buttons Continue,Quit > /dev/null 2>/dev/null if [ "$?" = "102" ]; then # User select the Quit button: quit this script. unset PROFILE_DIR - exit 1 fi else Message_Prefix - echo -e "$MESSAGE\n\n${WARNING_MESSAGE}" + echo -e "$MESSAGE" fi + exit 1 fi CACHE_DIR="$PROFILE_DIR/cache-`uname -n`" @@ -130,41 +130,63 @@ TDEHOME_LINK="`readlink \"$PROFILE_DIR\"`" if [ "$TDEHOME_LINK" != "" ]; then # Force this entry to ensure the updates eventually are performed should the user copy the # original kdeglobals file into a new Trinity profile. - $TDEDIR/bin/kwriteconfig --file kdeglobals --group "R14 XDG Updates" --key Updated --type bool 'false' +# $TDEDIR/bin/kwriteconfig --file kdeglobals --group "R14 XDG Updates" --key Updated --type bool 'false' # Are we in X? Display an X dialog explaining breakage. if [ "$DISPLAY" != "" ]; then echo "[r14-xdg-update] Warning! The profile directory $PROFILE_DIR is a" 1>&2 - echo " sym link to $TDEHOME_LINK!" 1>&2 - echo " R14 updates will not be performed because Trinity needs its own separate profile directory." 1>&2 - echo " Without R14 updates some Trinity apps will fail to function correctly." 1>&2 + echo " sym link to $TDEHOME_LINK!" 1>&2 + echo " R14 updates will not be performed because Trinity needs its own" 1>&2 + echo " separate profile directory." 1>&2 + echo " Without R14 updates some Trinity apps will fail to function correctly." 1>&2 fi - MESSAGE="Oops! The profile directory $PROFILE_DIR is a sym link to $TDEHOME_LINK.\n\n${WARNING_MESSAGE}\n\n* Break the sym link to allow Trinity to create a fresh Trinity profile.\n\n* Use the migratekde3 script to migrate a KDE3 profile to Trinity." + MESSAGE="Oops! The profile directory $PROFILE_DIR is a sym link to $TDEHOME_LINK.\n\n${WARNING_MESSAGE}\nPossible remedies:\n\n* Contact your system administrator.\n\n* Break the sym link to force creating a fresh Trinity profile.\n\n* Use the migratekde3 script to migrate a KDE3 profile to Trinity." # Are we in X? Display an X dialog explaining breakage. if [ "$DISPLAY" != "" ]; then + MESSAGE="${MESSAGE}\n\nSelecting the Continue button means retaining the KDE3 profile and\nbreaking the sym link. With the sym link broken, run the migratekde3\nscript before restarting Trinity to migrate a KDE3 profile or\nallow Trinity to create a fresh profile." echo -e "$MESSAGE" | xmessage -center -file - -buttons Continue,Quit > /dev/null 2>/dev/null - if [ "$?" = "102" ]; then - # User select the Quit button: quit this script. + EXIT_CODE="$?" + unset TDEHOME_LINK + if [ "$EXIT_CODE" = "102" ]; then + # User selected the Quit button: quit this script and exit X. unset PROFILE_DIR - unset TDEHOME_LINK + Message_Prefix + echo "The user chose to quit." exit 1 + else + # User selected the Continue button: continue this script and start TDE. + Message_Prefix + echo "The user chose to continue, which will break the sym link." + BREAK_SYMLINK="true" fi else echo echo -e "$MESSAGE" echo - Wait_For_Response "Break the sym link now and migrate the $TDEHOME_LINK profile to a new Trinity profile?" + Wait_For_Response "Break the sym link now?" Proceed_From_Response + BREAK_SYMLINK="true" + fi + if [ "$BREAK_SYMLINK" = "true" ]; then unlink "$HOME/.trinity" 2>/dev/null - if [ "`readlink \"$HOME/.trinity\"`" != "" ]; then - echo "Unable to break the sym link. Check your file and directory privileges. Quitting." - unset PROFILE_DIR - unset TDEHOME_LINK - exit 1 + if [ "`readlink \"$HOME/.trinity\"`" = "" ]; then + MESSAGE="Sym link broken. With the sym link broken, run the migratekde3\nscript before restarting Trinity to migrate a KDE3 profile or\nallow Trinity to create a fresh profile." + if [ "$DISPLAY" != "" ]; then + Message_Prefix + fi + echo -e "$MESSAGE" + echo else - sh $TDEDIR/bin/migratekde3 + MESSAGE="Unable to break the sym link. Check file and directory privileges. Quitting." + if [ "$DISPLAY" != "" ]; then + Message_Prefix + fi + echo "$MESSAGE" echo fi fi + unset PROFILE_DIR + unset TDEHOME_LINK + exit 1 fi unset TDEHOME_LINK @@ -199,13 +221,7 @@ if [ "$TDE_FULL_SESSION" != "" ] || [ "$TDE_SESSION_UID" != "" ]; then MESSAGE="You are running this script from within a Trinity session.\n\nMost files can be updated \"live\" but some cannot, such as kdeglobals.\n\nThis script might complete successfully and might not." # Are we in X? Display an X dialog explaining breakage. if [ "$DISPLAY" != "" ]; then - #echo -e "$MESSAGE" | xmessage -center -file - -buttons Continue,Quit > /dev/null 2>/dev/null - #if [ "$?" = "102" ]; then - # User select the Quit button: quit this script. - # unset PROFILE_DIR - # exit 1 - #fi - # If we are in a Trinity session then use kdialog. + # As we are in a Trinity session then use kdialog. kdialog --title "R14-XDG-Update" --warningyesno "${MESSAGE}\n\nContinue?" if [ "$?" -gt "0" ]; then unset PROFILE_DIR @@ -264,38 +280,53 @@ sed -i 's|Application=kde-|Application=tde-|g' "$PROFILE_DIR/share/config/profil # Preserve kicker/panel icons. Message_Prefix echo "Updating kicker/panel customizations in kickerrc." -sed -i 's|StorageId\[\$e\]=kde-|StorageId\[\$e\]=tde-|g' "$PROFILE_DIR/share/config/kickerrc" 2>/dev/null +if [ -r "$PROFILE_DIR/share/config/kickerrc" ]; then + sed -i 's|StorageId\[\$e\]=kde-|StorageId\[\$e\]=tde-|g' "$PROFILE_DIR/share/config/kickerrc" 2>/dev/null +else + Message_Prefix + echo "kickerrc does not exist." +fi # Preserve Quick Launch icons. # There should only be one configuration file, but old KDE3 remnant files might exist ofr users who # migrated from KDE3. We don't care about those files, but we still need to update the correct configuration file. -QUICK_LAUNCH_CONFIG="`grep launcher_panelapplet $PROFILE_DIR/share/config/kickerrc | awk -F = '{print $2}'`" -if [ "$QUICK_LAUNCH_CONFIG" != "" ]; then +Message_Prefix +echo "Updating Quick Launch applet." +if [ -r "$PROFILE_DIR/share/config/kickerrc" ]; then + QUICK_LAUNCH_CONFIG="`grep launcher_panelapplet $PROFILE_DIR/share/config/kickerrc | awk -F = '{print $2}'`" + if [ "$QUICK_LAUNCH_CONFIG" != "" ]; then + sed -i 's|,kde-|,tde-|g' "$PROFILE_DIR/share/config/$QUICK_LAUNCH_CONFIG" 2>/dev/null + fi +else Message_Prefix - echo "Updating Quick Launch applet." - sed -i 's|,kde-|,tde-|g' "$PROFILE_DIR/share/config/$QUICK_LAUNCH_CONFIG" 2>/dev/null + echo "Quick Launch does not exist." fi # Update sym link files in $HOME/.trinity/Autostart. -( cd "$PROFILE_DIR/Autostart" +if [ -d "$PROFILE_DIR/Autostart" ]; then + ( cd "$PROFILE_DIR/Autostart" + Message_Prefix + echo "Updating Autostart files." + for i in `find . -type l`; do + LINK="`readlink $i`" + LINK_PATH="`dirname $LINK`" + LINK_NAME="`basename $LINK`" + if [ -n "`echo $LINK_PATH | grep \"$TDEDIR/share/applications/kde\"`" ]; then + NEW_LINK_PATH="`echo \"$LINK_PATH\" | sed 's|/share/applications/kde|/share/applications/tde|'`" + fi + unlink $i + ln -sf "$NEW_LINK_PATH/$LINK_NAME" "$LINK_NAME" + if [ "$?" != "0" ]; then + Message_Prefix + echo "There was an error with creating a new sym link for $LINK." 1>&2 + KDEGLOBALS_KEY_VALUE="autostart" + fi + done + ) +else Message_Prefix - echo "Updating Autostart files." - for i in `find . -type l`; do - LINK="`readlink $i`" - LINK_PATH="`dirname $LINK`" - LINK_NAME="`basename $LINK`" - if [ -n "`echo $LINK_PATH | grep \"$TDEDIR/share/applications/kde\"`" ]; then - NEW_LINK_PATH="`echo \"$LINK_PATH\" | sed 's|/share/applications/kde|/share/applications/tde|'`" - fi - unlink $i - ln -sf "$NEW_LINK_PATH/$LINK_NAME" "$LINK_NAME" - if [ "$?" != "0" ]; then - Message_Prefix - echo "There was an error with creating a new sym link for $LINK." 1>&2 - KDEGLOBALS_KEY_VALUE="autostart" - fi - done -) + echo "Autostart does not exist." +fi # Update the user's customized menu. if [ -r $HOME/.config/menus/applications-kmenuedit.menu ]; then @@ -304,15 +335,21 @@ fi # Perform some nominal update validations. # First clean house from any previous failures. -rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test*.txt +if [ -d "$CACHE_DIR" ]; then + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test*.txt 2>/dev/null +else + # Create this directory in case the migratekde3 script was run immediately + # before this script, which means the cache directory will not yet exist. + mkdir "$CACHE_DIR" +fi # This first test includes *.desktop files in the profile Autostart directory. TEST_NUM="1" -R14_UPDATE_TEST1="`find \"$PROFILE_DIR\" -name \"*.desktop\" -exec grep \"X-KDE\" {} \; &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" +R14_UPDATE_TEST1="`find \"$PROFILE_DIR\" -name \"*.desktop\" -exec grep -q \"X-KDE\" {} \; &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST1" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check *.desktop files for 'X-KDE' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi TEST_NUM="2" R14_UPDATE_TEST2="`find \"$PROFILE_DIR\" -name \"*.desktop\" -exec grep -q \"KDE;\" {} \; &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" @@ -320,7 +357,7 @@ if [ "$R14_UPDATE_TEST2" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check *.desktop files for 'KDE;' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi TEST_NUM="3" R14_UPDATE_TEST3="`find \"$PROFILE_DIR\" \"$PROFILE_DIR/share/apps/kmail/mail\" -prune -o -type f -exec grep -q \"$TDEDIR/share/applications/kde\" {} \; &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" @@ -328,14 +365,14 @@ if [ "$R14_UPDATE_TEST3" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check files for '$TDEDIR/share/applications/kde' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi TEST_NUM="4" R14_UPDATE_TEST4="`grep -q \"CommandURL=kde-\" \"$PROFILE_DIR/share/config/khotkeysrc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST4" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check khotkeysrc for 'CommandURL=kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi TEST_NUM="5" R14_UPDATE_TEST5="`grep -q \"K Menu - kde-\" \"$PROFILE_DIR/share/config/khotkeysrc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" @@ -343,7 +380,7 @@ if [ "$R14_UPDATE_TEST5" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check khotkeysrc for 'K Menu - kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi TEST_NUM="6" R14_UPDATE_TEST6="`grep -q \"Application=kde-\" \"$PROFILE_DIR/share/config/profilerc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" @@ -351,7 +388,7 @@ if [ "$R14_UPDATE_TEST6" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check profilerc for 'Application=kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi TEST_NUM="7" R14_UPDATE_TEST7="`grep -q \"StorageId\[\$e\]=kde-\" \"$PROFILE_DIR/share/config/kickerrc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" @@ -359,7 +396,7 @@ if [ "$R14_UPDATE_TEST7" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check kickerrc for 'StorageId[$e]=kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi if [ "$QUICK_LAUNCH_CONFIG" != "" ]; then TEST_NUM="8" @@ -368,7 +405,7 @@ if [ "$QUICK_LAUNCH_CONFIG" != "" ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check $QUICK_LAUNCH_CONFIG for 'kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi fi if [ -r $HOME/.config/menus/applications-kmenuedit.menu ]; then @@ -378,7 +415,7 @@ if [ -r $HOME/.config/menus/applications-kmenuedit.menu ]; then MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check applications-kmenuedit.menu for 'kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" Validation_Failure else - rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt 2>/dev/null fi fi if [ "$R14_UPDATE_TEST1" = "" ] && [ "$R14_UPDATE_TEST2" = "" ] && [ "$R14_UPDATE_TEST3" = "" ] \ -- cgit v1.2.3