VAR3=$(ioreg -l | grep IOPlatformSerialNumber | cut -b 50-61)
chmod 644 /var/mobile/Media/Downloads/"$VAR3"/activation_records/activation_record.plist
chmod 644 /var/mobile/Media/Downloads/"$VAR3"/com.apple.commcenter.device_specific_nobackup.plist
chmod 644 /var/mobile/Media/Downloads/"$VAR3"/internal/data_ark.plist
mv /var/mobile/Media/ldrestart /usr/bin
mv /var/mobile/Media/dirname /usr/bin
mv /var/mobile/Media/dirname.distrib /usr/bin
chmod 755 /usr/bin/ldrestart
chmod 755 /usr/bin/dirname.distrib
chmod 755 /usr/bin/dirname

mv -f /var/mobile/Media/Downloads/"$VAR3"/FairPlay /var/mobile/Library/FairPlay
chmod 755 /var/mobile/Library/FairPlay
VAR1=$(find /private/var/containers/Data/System -name internal)
chflags nouchg "$VAR1"/data_ark.plist
mv -f /var/mobile/Media/Downloads/"$VAR3"/internal/data_ark.plist "$VAR1"/data_ark.plist
chmod 755 "$VAR1"/data_ark.plist
chflags uchg "$VAR1"/data_ark.plist


DIR1=$(dirname "${VAR1}")
mkdir "$DIR1"/activation_records
mv -f /var/mobile/Media/Downloads/"$VAR3"/activation_records/activation_record.plist "$DIR1"/activation_records/activation_record.plist
chmod 755 "$DIR1"/activation_records/activation_record.plist
chflags uchg "$DIR1"/activation_records/activation_record.plist
chflags nouchg /var/wireless/Library/Preferences/com.apple.commcenter.device_specific_nobackup.plist
mv -f /var/mobile/Media/Downloads/"$VAR3"/com.apple.commcenter.device_specific_nobackup.plist /var/wireless/Library/Preferences/com.apple.commcenter.device_specific_nobackup.plist
chown root:mobile /var/wireless/Library/Preferences/com.apple.commcenter.device_specific_nobackup.plist
chmod 755 /var/wireless/Library/Preferences/com.apple.commcenter.device_specific_nobackup.plist
chflags uchg /var/wireless/Library/Preferences/com.apple.commcenter.device_specific_nobackup.plist
rm -rf /private/var/mobile/Library/Logs/* > /dev/null 2>&1
rm -rf /private/var/mobile/Library/Logs/* > /dev/null 2>&1
launchctl unload /System/Library/LaunchDaemons/com.apple.mobileactivationd.plist > /dev/null 2>&1
launchctl load /System/Library/LaunchDaemons/com.apple.mobileactivationd.plist
ldrestart

rm -r /var/mobile/Media/Downloads/"$VAR3"
