View Single Post
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#12
Originally Posted by AgogData View Post
i tried it but didn't work, i suppose its a command to replace all the enables words with disables..if thats so i opened catalogues file and there were no "enable" word there, only disable for a couple of catalogues i disabled before.
You're right - I thought I'd checked for that

You could also try creating an empty catalogue file and swapping the two around. The following script will do this, and enable you to switch between them:
Code:
#!/bin/sh

ACTION=$1
CAT_DIR=/etc/hildon-application-manager
DEF_CAT=catalogues
DISABLED_CAT=catalogues.disabled
ENABLED_CAT=catalogues.enabled
CUR_STATUS=""

move_catalogues() {
        NEW_CAT=$1
        OLD_CAT=$2

        mv "$CAT_DIR/$DEF_CAT" "$CAT_DIR/$OLD_CAT" && mv "$CAT_DIR/$NEW_CAT" "$CAT_DIR/$DEF_CAT"
}

if [ ! -f "$CAT_DIR/$DEF_CAT" ]; then
        echo "No primary catalogue file found. Please fix before rerunning."
        exit 1
fi

if [ -f "$CAT_DIR/$ENABLED_CAT" ]; then
        CUR_STATUS=disabled
fi

if [ -f "$CAT_DIR/$DISABLED_CAT" ]; then
        if [ -n "$CUR_STATUS" ]; then
                echo "Cannot determine status."
                exit 1
        fi

        CUR_STATUS=enabled
fi

if [ -z "$CUR_STATUS" ]; then
        echo "<catalogues/>" > "$CAT_DIR/$DISABLED_CAT"
        CUR_STATUS="enabled"
fi

if [ "$ACTION" == "enable" ]; then
        if [ "$CUR_STATUS" == "enabled" ]; then
                echo "Already enabled"
                exit 0
        fi

        move_catalogues $ENABLED_CAT $DISABLED_CAT
elif [ "$ACTION" == "disable" ]; then
        if [ "$CUR_STATUS" == "disabled" ]; then
                echo "Already disabled"
                exit 0
        fi

        move_catalogues $DISABLED_CAT $ENABLED_CAT
elif [ "$ACTION" == "status" ]; then
        echo $CUR_STATUS
else
        echo "Unknown action"
        exit 1
fi

exit $?
It accepts one of three arguments - enable, disable or status (which reports what the current state is).
 

The Following 3 Users Say Thank You to Rob1n For This Useful Post: