#!/bin/bash
proc_plist=/Library/MobileSubstrate/DynamicLibraries/disabled/$1.plist
proc_dlib=/Library/MobileSubstrate/DynamicLibraries/disabled/$1.dylib
procd_dlib=/Library/MobileSubstrate/DynamicLibraries/$1.dylib
if [ "$EUID" -eq 0 ]; then
        if [ $1 == "help" ]; then
                echo "Usage: enablet [tweak]
                help: prints this help file
                list: lists all packages currently enabled
                [tweak]: input the name of a tweak's dylib to enable it "
        elif [ $1 == "list" ]; then
                directory=/Library/MobileSubstrate/DynamicLibraries/disabled/*
                for file in $directory; do
                        echo $(basename $file)
                done
        elif test -e "$proc_dlib"; then
                echo $1 is disabled.
                echo Enabling...
                mv $proc_dlib /Library/MobileSubstrate/DynamicLibraries/
                mv $proc_plist /Library/MobileSubstrate/DynamicLibraries/
                echo $1 enabled.
        elif  test -e "$procd_dlib" ; then
                echo $1 is already enabled.
        else
                echo $1 is either inputted incorrectly, not installed or does not have a dyli$
                echo "Usage: enablet [tweak]
                help: prints this help file
                list: lists all packages currently enabled
                [tweak]: input the name of a tweak's dylib to enable it"
        fi
else
        echo enablet needs to be run as root.
fi