Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit 8666c06

Browse files
committed
boom boom
1 parent 1e0e4dd commit 8666c06

File tree

1 file changed

+121
-108
lines changed

1 file changed

+121
-108
lines changed

azule

Lines changed: 121 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -6,88 +6,6 @@ shopt -s extglob
66
# SAVE INITIAL DIRECTORY
77
rootdir="$PWD"
88

9-
# SET PLATFORM
10-
case "$(uname -s)" in
11-
"Linux") os="Linux" ;;
12-
"Darwin")
13-
if [ "$(sw_vers | grep 'ProductName:' | cut -d: -f2 | xargs)" == "macOS" ]; then
14-
os="MacOS"
15-
else
16-
os="iOS"
17-
fi
18-
;;
19-
esac
20-
21-
# PLATFORM-SPECIFIC FUNCTIONS
22-
case "$os" in
23-
iOS)
24-
RemovePlistKey () {
25-
plutil -remove -key "$1" "$2" &>/dev/null
26-
}
27-
28-
ReplacePlistValue () {
29-
plutil -value "$1" -key "$2" "$3" &>/dev/null
30-
}
31-
32-
ExtractPlistValue () {
33-
status=0
34-
if [ -n "$3" ]; then
35-
plutil -key "$1" "$2" >> tmp 2>/dev/null || status=1
36-
plutil -convert xml1 tmp &>/dev/null || status=1
37-
sed -n "s/.*<key>\(.*\)<\/key>.*/\1/p" tmp || status=1
38-
rm tmp &>/dev/null || status=1
39-
else
40-
plutil -key "$1" "$2" 2>/dev/null || status=1
41-
fi
42-
return $status
43-
}
44-
45-
ExtractDEB () {
46-
Announce "Extracting $(basename "$1")..."
47-
dpkg -x "$1" "$dir/Tweak"
48-
Verbose "Extracted $(basename "$1")" "Couldn't extract $(basename "$1")" 3
49-
}
50-
;;
51-
52-
MacOS|Linux)
53-
RemovePlistKey () {
54-
plutil -remove "$1" "$2" &>/dev/null
55-
}
56-
57-
ReplacePlistValue () {
58-
plutil -replace "$2" -string "$1" "$3" &>/dev/null
59-
}
60-
61-
ExtractPlistValue () {
62-
if [ -n "$3" ]; then
63-
psed="key"
64-
else
65-
psed="string"
66-
fi
67-
value="$(plutil -extract "$1" xml1 -o - "$2" | sed -n "s/.*<$psed>\(.*\)<\/$psed>.*/\1/p" 2>/dev/null)"
68-
69-
if [ -n "$value" ]; then
70-
echo "$value"
71-
else
72-
return 1
73-
fi
74-
}
75-
76-
ExtractDEB () {
77-
origin_dir="$PWD"
78-
mkdir -p "$dir/debtemp/$1"
79-
cd "$dir/debtemp/$1" || exit
80-
Announce "Extracting $(basename "$1")..." -v
81-
ar -x "$1" || status=1
82-
tar -C "$dir/Tweak" -xf data.tar.* || status=1
83-
Verbose "Extracted $(basename "$1")" "Couldn't extract $(basename "$1")" 5 -x
84-
cd "$origin_dir" || exit
85-
rm -rf "$dir/debtemp/$1"
86-
return $status
87-
}
88-
;;
89-
esac
90-
919
# UNIVERSAL FUNCTIONS
9210
Announce () {
9311
unset mute_verbose
@@ -417,6 +335,7 @@ help () {
417335
echo " -y Don't remove watch app"
418336
echo " -q Ignore errors"
419337
echo " -z Don't compress .app file before writing"
338+
echo " -j Allow for Azule to be ran as root [Not Reccommended]"
420339
echo " -h Print this help menu"
421340

422341
if [ "$os" == "iOS" ]; then
@@ -435,12 +354,97 @@ help () {
435354
cleanup
436355
}
437356

357+
# SET PLATFORM
358+
case "$(uname -s)" in
359+
"Linux") os="Linux" ;;
360+
"Darwin")
361+
if [ "$(sw_vers | grep 'ProductName:' | cut -d: -f2 | xargs)" == "macOS" ]; then
362+
os="MacOS"
363+
else
364+
os="iOS"
365+
fi
366+
;;
367+
esac
368+
369+
# ANNOUNCE PLATFORM
370+
Announce "Platform is $os" -v
371+
372+
# PLATFORM-SPECIFIC FUNCTIONS
373+
case "$os" in
374+
iOS)
375+
RemovePlistKey () {
376+
plutil -remove -key "$1" "$2" &>/dev/null
377+
}
378+
379+
ReplacePlistValue () {
380+
plutil -value "$1" -key "$2" "$3" &>/dev/null
381+
}
382+
383+
ExtractPlistValue () {
384+
status=0
385+
if [ -n "$3" ]; then
386+
plutil -key "$1" "$2" >> tmp 2>/dev/null || status=1
387+
plutil -convert xml1 tmp &>/dev/null || status=1
388+
sed -n "s/.*<key>\(.*\)<\/key>.*/\1/p" tmp || status=1
389+
rm tmp &>/dev/null || status=1
390+
else
391+
plutil -key "$1" "$2" 2>/dev/null || status=1
392+
fi
393+
return $status
394+
}
395+
396+
ExtractDEB () {
397+
Announce "Extracting $(basename "$1")..."
398+
dpkg -x "$1" "$dir/Tweak"
399+
Verbose "Extracted $(basename "$1")" "Couldn't extract $(basename "$1")" 3
400+
}
401+
;;
402+
403+
MacOS|Linux)
404+
RemovePlistKey () {
405+
plutil -remove "$1" "$2" &>/dev/null
406+
}
407+
408+
ReplacePlistValue () {
409+
plutil -replace "$2" -string "$1" "$3" &>/dev/null
410+
}
411+
412+
ExtractPlistValue () {
413+
if [ -n "$3" ]; then
414+
psed="key"
415+
else
416+
psed="string"
417+
fi
418+
value="$(plutil -extract "$1" xml1 -o - "$2" | sed -n "s/.*<$psed>\(.*\)<\/$psed>.*/\1/p" 2>/dev/null)"
419+
420+
if [ -n "$value" ]; then
421+
echo "$value"
422+
else
423+
return 1
424+
fi
425+
}
426+
427+
ExtractDEB () {
428+
origin_dir="$PWD"
429+
mkdir -p "$dir/debtemp/$1"
430+
cd "$dir/debtemp/$1" || exit
431+
Announce "Extracting $(basename "$1")..." -v
432+
ar -x "$1" || status=1
433+
tar -C "$dir/Tweak" -xf data.tar.* || status=1
434+
Verbose "Extracted $(basename "$1")" "Couldn't extract $(basename "$1")" 5 -x
435+
cd "$origin_dir" || exit
436+
rm -rf "$dir/debtemp/$1"
437+
return $status
438+
}
439+
;;
440+
esac
441+
438442
# CLEAN ON EXIT
439443
trap "cleanup" SIGINT
440444
trap "cleanup" EXIT
441445

442446
# CLI ARGUEMENTS
443-
while getopts Hn:i:o:c:b:x:f:p:huSewsrDHqAdRyUzgFLklv args; do
447+
while getopts Hn:i:o:c:b:x:f:p:huSewsrDHqAdjRyUzgFLklv args; do
444448

445449
# STUFF WITH PARAMETERS
446450
if [[ "$args" == @(x|n|b|p|i|o|c|f|A|H) ]]; then
@@ -475,6 +479,7 @@ while getopts Hn:i:o:c:b:x:f:p:huSewsrDHqAdRyUzgFLklv args; do
475479

476480
# SWITCHES
477481
e) remove_extensions=1 && run=1 ;;
482+
j) allow_root_run=1 ;;
478483
q) ignore_errors=1 ;;
479484
r) ignore_encrypted=1 ;;
480485
s) silent_run=1 ;;
@@ -504,8 +509,10 @@ while getopts Hn:i:o:c:b:x:f:p:huSewsrDHqAdRyUzgFLklv args; do
504509
esac
505510
done
506511

507-
# ANNOUNCE PLATFORM
508-
Announce "Platform is $os" -v
512+
# USER CHECK
513+
if [ "$(id -u)" == "0" ] && [ -z "$allow_root_run" ]; then
514+
Announce "Azule should not be ran as root. Use '-j' to overwrite" 36
515+
fi
509516

510517
# PLATFORM-SPECIFIC VARIABLES
511518
case "$os" in
@@ -1072,29 +1079,35 @@ if [ -n "${files[*]}" ]; then
10721079
Verbose "Copied $(basename "$i") to app directory" "$(basename "$i") couldn't be copied to app directory" 16 -v
10731080
else
10741081
identifier="$(ExtractPlistValue Filter "${i%.*}".plist)"
1075-
split_array idtypes "$(ExtractPlistValue Filter "${i%.*}".plist key)"
1076-
for idtype in "${idtypes[@]}"; do
1077-
case "$idtype" in
1078-
Bundles)
1079-
ipabundleid="$(ExtractPlistValue CFBundleIdentifier Payload/"$appname"/Info.plist)"
1080-
if [[ "$identifier" =~ $ipabundleid ]]; then
1081-
inject+=( "$copy_path" )
1082-
cp -a "$i" "$copy_path"
1083-
Verbose "Copied $(basename "$i") to app directory" "$(basename "$i") couldn't be copied to app directory" 16 -v
1084-
break
1085-
fi
1086-
;;
1087-
1088-
Executables)
1089-
if [[ "$identifier" =~ $(basename "$executable") ]]; then
1090-
inject+=( "$copy_path" )
1091-
cp -a "$i" "$copy_path"
1092-
Verbose "Copied $(basename "$i") to app directory" "$(basename "$i") couldn't be copied to app directory" 16 -v
1093-
break
1094-
fi
1095-
;;
1096-
esac
1097-
done
1082+
if ! [[ "$identifier" =~ ^[0-9a-zA-Z]+$ ]]; then
1083+
inject+=( "$copy_path" )
1084+
lib_dylibs+=( "$copy_path" )
1085+
cp -a "$i" "$copy_path"
1086+
Verbose "Copied $(basename "$i") to app directory" "$(basename "$i") couldn't be copied to app directory" 16 -v
1087+
else
1088+
split_array idtypes "$(ExtractPlistValue Filter "${i%.*}".plist key)"
1089+
for idtype in "${idtypes[@]}"; do
1090+
case "$idtype" in
1091+
Bundles)
1092+
if [[ "$identifier" =~ $(ExtractPlistValue CFBundleIdentifier Payload/"$appname"/Info.plist) ]]; then
1093+
inject+=( "$copy_path" )
1094+
cp -a "$i" "$copy_path"
1095+
Verbose "Copied $(basename "$i") to app directory" "$(basename "$i") couldn't be copied to app directory" 16 -v
1096+
break
1097+
fi
1098+
;;
1099+
1100+
Executables)
1101+
if [[ "$identifier" =~ $(basename "$executable") ]]; then
1102+
inject+=( "$copy_path" )
1103+
cp -a "$i" "$copy_path"
1104+
Verbose "Copied $(basename "$i") to app directory" "$(basename "$i") couldn't be copied to app directory" 16 -v
1105+
break
1106+
fi
1107+
;;
1108+
esac
1109+
done
1110+
fi
10981111
fi
10991112
done < <(find "$dir/Tweak" "$dir/Custom" ! -type l -iname '*.dylib' 2>/dev/null)
11001113

0 commit comments

Comments
 (0)