答案 0 :(得分:0)
如上所述,足以查看文件的不同之处,并在这些行中替换扮演类似角色的部分。在这种情况下,您可以使用单个变量来完成。如果受{}
保护,则更好
在这种情况下,您可以运行脚本并将所需的子路径传递给它:
./myscript.sh ../Napster.app/it.lproj
或
./myscript.sh ../Napster.app
如果您在没有参数的情况下运行它,它将用作默认../Napster.app/it.lproj
#!/bin/sh
MyPath=${1:-../Napster.app/it.lproj"}
if [ -f "/var/mobile/temp.temp" ];then
rm "/var/mobile/temp.temp"
fi
ls -d /var/mobile/Applications/*/*.app | sort -f -t \/ -k 6 | while read OneApp
do
AppName=$(echo $OneApp | cut -f 6 -d '/')
cd "$OneApp";
devicebundleid=$(plutil -key CFBundleIdentifier Info.plist)
if [ "$devicebundleid" = "com.rhapsody.iphone.Napster3" ]; then
pwd >/var/mobile/temp.temp
fi
done
if [ ! -f "/var/mobile/temp.temp" ];then
echo "Napster not found. if your sure its install please report to the repo manager"
else
dir=$(cat "/var/mobile/temp.temp")
backup="$dir/../backup.tar.gz"
gamefiles=/files.tmp
hackedfiles=/hackedfiles.tmp
matchingfiles=/matchingfiles.tmp
itunesmeta=$dir/../iTunesMetadata.plist
info=$dir/Info.plist
binname=$(plutil -key CFBundleExecutable $dir/Info.plist)
if [ -f $dir/../iTunesMetadata.plist ];then
if grep -q "bundleShortVersionString" "$itunesmeta"
then myappver=$(plutil -key bundleShortVersionString $itunesmeta)
else myappver=$(plutil -key bundleVersion $itunesmeta)
fi
else
plutil -xml $info 2>&1>/dev/null
if grep -q "CFBundleShortVersionString" "$info"
then myappver=$(plutil -key CFBundleShortVersionString $info)
else myappver=$(plutil -key CFBundleVersion $info)
fi
fi
echo "###########"
echo "# Description #"
echo "###########"
echo "XX SUPERGIU XX"
sleep 1
echo
echo "######"
echo "# Log #"
echo "######"
echo -n " -Checking Files..."
if [ ! -d "/hack" ]; then
echo
echo " *** Error ***"
echo
echo "***********************************************"
echo " *No files found in /hack***"
echo " *Please report this to the repo manager"
echo
echo "***********************************************"
echo
exit 0
else
sleep 1
echo " Success"
fi
echo -n " -Finding Napster..."
sleep 1
echo " Success"
echo -n " -Locating Matching Files..."
sleep .1
echo " Success"
echo -n " -Making Backup..."
ls $dir/${MyPath}/ >$gamefiles
ls "/hack" >$hackedfiles
grep -i -E -f $gamefiles $hackedfiles >$matchingfiles
for line in `cat $matchingfiles`
do tar -pczf "$dir/../backup.tar.gz" "$dir/${MyPath}/$line"&>/dev/null
done
if [ -f "$dir/../backup.tar.gz" ]; then
sleep 1
echo " Success"
else
sleep 1
echo " *** Error ***"
echo
echo "***********************************************"
echo " *Backup not needed, not replacing anything"
echo
echo "***********************************************"
fi
echo -n " -Checking App Version..."
if [ ! "200" == "$myappver" ]; then
sleep 1
echo " *** Error ***"
echo
echo "***********************************************"
echo "*** Your app is version $myappver ***"
echo "*** This file is for 200 ***"
echo "*** It may not work, please get version 200 ***"
echo
echo "***********************************************"
else
sleep 1
echo " Success"
fi
echo -n " -Patching Files..."
sleep 1
echo " Success"
mv -f /hack/* "$dir/${MyPath}/"
echo -n " -Setting Ownership and Permissions..."
sleep 1
echo " Success"
chmod -R 755 "$dir/${MyPath}/"
chown -R mobile.mobile "$dir/${MyPath}/"
if [ $sign = "1" ];then
ldone "$dir/$binname" -s
fi
echo -n " -Cleaning Up..."
sleep 1
echo " Success"
rm -f $gamefiles $hackedfiles $matchingfiles $dirfile
rmdir /hack
echo " -Successfully Done :)"
sleep .5
echo
echo "###########"
echo "# Credits #"
echo "###########"
echo " -By SUPERGIU"
echo
fi