219 lines
7.3 KiB
Bash
Executable file
219 lines
7.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
flasbackDir="/Library/FlashBack"
|
|
if [ ! -d $flasbackDir/Backups ]; then
|
|
mkdir $flasbackDir
|
|
mkdir $flasbackDir/Backups
|
|
fi
|
|
|
|
pause(){
|
|
read -p "Press return key to continue..." fackEnterKey
|
|
}
|
|
|
|
one(){ #Backup current preferences
|
|
echo " "
|
|
read -p "Enter Backup Name: " backupName #Enter the name of the backup
|
|
read -p "Enter Your UserName: " userName #Enter the name of the setup creator
|
|
read -p "Enter A Short Description: " userDesc #Enter a description
|
|
backupLocation="$flasbackDir/Backups/"$backupName #backup folder with backup's name
|
|
mkdir $backupLocation #Creates backup folder
|
|
mkdir $backupLocation/Preferences #Creates Backup Preference Folder
|
|
mkdir $backupLocation/IconLayout #Creates Backup Icon Layout Folder
|
|
mkdir $backupLocation/Wallpaper #Creates Backup Wallpaper Folder
|
|
|
|
echo " "
|
|
echo "Would you like to specify dependancies?"
|
|
echo "If so, it's recommended to use iCleaner Pro to clean up unused preference files before you start."
|
|
echo " "
|
|
echo "AutoMatic: You select which packages are dependancies, for a streamlined installation."
|
|
echo "Manual: Dependancies are not set for users, they must install the tweaks themselves."
|
|
echo " "
|
|
read -p "Type 'yes' to proceed in automatic mode, press enter to use manual mode: " autoMode #User will specify which packages are backed up and depended upon
|
|
|
|
if [[ $autoMode = "yes" ]]
|
|
then
|
|
echo " "
|
|
read -p "Staring automatic mode. A list of installed packages will appear in a moment. Use that list to select which packages are dependancies. Press enter to proceed."
|
|
apt-mark auto "gsc*" &> /dev/null
|
|
echo " "
|
|
apt-mark showmanual
|
|
read -p "Please copy all desired dependancies from above EXACTLY as they are displayed. Separate them with a comma and a space (, ): " userSetDependancies
|
|
fi
|
|
|
|
echo "Copying to "$backupLocation"..."
|
|
excludeApple="!(com.apple*,com.saurik*).plist"
|
|
cp -r -f "/var/mobile/Library/Preferences/"$excludeApple $backupLocation/Preferences/ #copy all non-apple Plists to Preference folder within backup haha
|
|
cp -r -f /var/mobile/Library/SpringBoard/IconState.plist $backupLocation/IconLayout/IconState.plist #copy IconState Plist to IconLayout folder within backup
|
|
cp -r -f /var/mobile/Library/SpringBoard/*Background* $backupLocation/Wallpaper/ #copy Wallpaper & data to Wallpaper folder within backup
|
|
|
|
echo " "
|
|
echo "Creating Control File..."
|
|
|
|
if [[ $autoMode = "yes" ]]
|
|
then
|
|
|
|
cat > $backupLocation/control <<EOF
|
|
|
|
Package: com.$userName.$backupName
|
|
Name: $backupName
|
|
Depends: com.mpg13.FlashBack, $userSetDependancies
|
|
architecture: iphoneos-arm
|
|
Version:1.0
|
|
Description: $userDesc
|
|
Maintainer: $userName
|
|
Author: $userName
|
|
Section: Addons (FlashBack)
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
cat > $backupLocation/control <<EOF
|
|
|
|
Package: com.$userName.$backupName
|
|
Name: $backupName
|
|
Depends: com.mpg13.FlashBack
|
|
architecture: iphoneos-arm
|
|
Version:1.0
|
|
Description: $userDesc
|
|
Maintainer: $userName
|
|
Author: $userName
|
|
Section: Addons (FlashBack)
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
echo "Succeeded!"
|
|
|
|
pause
|
|
}
|
|
|
|
two(){ #Restore backup functions
|
|
echo " "
|
|
echo "Available Backups:"
|
|
echo " "
|
|
ls $flasbackDir/Backups/ #List all Backup Folders which match their names
|
|
echo " "
|
|
read -p "Choose a Backup: " selectedBackup #Let user select which backup
|
|
selectedLocation=$flasbackDir"/Backups/"$selectedBackup #uses variable to determine backup to use
|
|
autoBackupLocation=$flasbackDir"/Backups/AutoBackup_"$(date '+%d-%m-%Y_%H:%M:%S') #Sets autobackup location with date and time
|
|
mkdir $autoBackupLocation #Creates autobackup folder
|
|
mkdir $autoBackupLocation/Preferences #Creates autobackup Preference Folder
|
|
mkdir $autoBackupLocation/IconLayout #Creates autobackup Preference Folder
|
|
mkdir $autoBackupLocation/Wallpaper #Creates autobackup Preference Folder
|
|
echo "Moving current Preferences to "$autoBackupLocation"..."
|
|
excludeApple="!(com.apple*,com.saurik*).plist"
|
|
cp "/var/mobile/Library/Preferences/"$excludeApple $autoBackupLocation/Preferences/ #Copy copy all non-apple Plists to Preference folder within autobackup haha
|
|
cp -r -f /var/mobile/Library/SpringBoard/IconState.plist $autoBackupLocation/IconLayout/IconState.plist #copy IconState Plist to IconLayout folder within backup
|
|
cp -r -f /var/mobile/Library/SpringBoard/*Background* $autoBackupLocation/Wallpaper/ #copy Wallpaper & data to Wallpaper folder within backup
|
|
echo " "
|
|
echo "Copying Backup to appropriate system directories..."
|
|
cp -r $selectedLocation/Preferences/*.plist /var/mobile/Library/Preferences/ #Copy all Plists from backup Preference folder to System Preferences
|
|
cp $selectedLocation/IconLayout/IconState.plist /var/mobile/Library/SpringBoard/IconState.plist #Copy all Plists from backup Preference folder to System Icon layout
|
|
cp -r $selectedLocation/Wallpaper/*Background* /var/mobile/Library/SpringBoard/ #Copy all Plists from backup Preference folder to System wallpaper
|
|
echo "Rebuilding UI cache and Killing SpringBoard..."
|
|
uicache #Rebuilds UI Cache - hopefully this doesn't break anything.
|
|
read -p "Press enter one more time, please."
|
|
uicache
|
|
echo "Thanks for using FlashBack!"
|
|
killall SpringBoard
|
|
pause
|
|
}
|
|
|
|
three(){
|
|
echo "Available Backups:"
|
|
echo " "
|
|
ls $flasbackDir/Backups/ #Lists all backups
|
|
echo " "
|
|
read -p "Choose a Backup: " deleteBackup #User selects backup to delete
|
|
deleteLocation=$flasbackDir"/Backups/"$deleteBackup #location from selected backup
|
|
echo "Deleting "$deleteBackup"..."
|
|
rm -r $deleteLocation #delete backup folder
|
|
pause
|
|
}
|
|
|
|
four(){
|
|
read -p "Are you sure you want to delete all autobackups? (y/n): " shouldDeleteAB
|
|
if [[ $shouldDeleteAB = "y" ]]
|
|
then
|
|
echo "Deleting all autobackups..."
|
|
rm -r $flasbackDir/Backups/AutoBackup* #Delete all folders that start with AutoBackup
|
|
else
|
|
echo "Not deleting autobackups!"
|
|
fi
|
|
pause
|
|
}
|
|
|
|
five(){
|
|
echo "Available Backups:"
|
|
echo " "
|
|
ls $flasbackDir/Backups/ #Lists all backups
|
|
echo " "
|
|
read -p "Choose a Backup: " packageBackup #User selects backup to package, hopefully
|
|
|
|
echo "Creating working directory..."
|
|
mkdir $flasbackDir/working
|
|
workingDir=$flasbackDir/working/$packageBackup
|
|
echo "Creating debian layout..."
|
|
mkdir $workingDir
|
|
mkdir $workingDir/DEBIAN/
|
|
mkdir $workingDir/Library/
|
|
mkdir $workingDir/Library/FlashBack/
|
|
mkdir $workingDir/Library/FlashBack/Backups/
|
|
mkdir $workingDir/Library/FlashBack/Backups/$packageBackup
|
|
|
|
echo "Copying backup to debian format..."
|
|
cp $flasbackDir"/Backups/"$packageBackup/control $workingDir/DEBIAN/
|
|
excludeControl="!(control*)"
|
|
cp -r $flasbackDir"/Backups/"$packageBackup/$excludeControl $workingDir/Library/FlashBack/Backups/$packageBackup/
|
|
|
|
echo "Packaging DEB..."
|
|
dpkg-deb -Zgzip -b $workingDir
|
|
echo "Moving DEB..."
|
|
cp $workingDir.deb $flasbackDir
|
|
echo "Cleaning working directory..."
|
|
rm -r -f $flasbackDir/working
|
|
echo " "
|
|
echo "The DEB can be found in "$flasbackDir"/"$packageBackup".deb"
|
|
|
|
pause
|
|
}
|
|
|
|
show_menus() {
|
|
clear
|
|
echo "~~~~~~~~~~~~~~~~~~~~~"
|
|
echo " FlashBack "
|
|
echo " This software is in"
|
|
echo " BETA. Use it at your"
|
|
echo " own risk!"
|
|
echo "~~~~~~~~~~~~~~~~~~~~~"
|
|
echo "1. Backup Current Preferences"
|
|
echo "2. Restore Backup"
|
|
echo "3. Delete Backups"
|
|
echo "4. Delete AutoBackups"
|
|
echo "5. Package Backup to DEB"
|
|
echo "6. Quit"
|
|
}
|
|
|
|
read_options(){
|
|
local choice
|
|
read -p "Enter choice [ 1 - 6] " choice
|
|
case $choice in
|
|
1) one ;;
|
|
2) two ;;
|
|
3) three ;;
|
|
4) four ;;
|
|
5) five;;
|
|
6) exit 0;;
|
|
*) echo "Invalid Selection!" && sleep 2
|
|
esac
|
|
}
|
|
|
|
while true
|
|
do
|
|
shopt -s extglob
|
|
show_menus
|
|
echo " "
|
|
read_options
|
|
done
|