-
Notifications
You must be signed in to change notification settings - Fork 4
/
rc.local
executable file
·61 lines (52 loc) · 1.71 KB
/
rc.local
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
# Disable wifi
sudo iwconfig wlan0 txpower off
# Disable ethernet
sudo ip link set eth0 down
# Watch for mounted devices
cd /media/
for i in `seq 1 100`;
do
# Search for *.apk
APK="$(find $PWD -type f -name "*.apk" -not -path "*/\.*" | head -n 1)"
# Search for *.keystore
KEYSTORE="$(find $PWD -type f -name "*.keystore" | head -n 1)"
KEYPASS="$(find $PWD -type f -name "key-pass.txt" | head -n 1)"
KSPASS="$(find $PWD -type f -name "ks-pass.txt" | head -n 1)"
ALIAS="$(find $PWD -type f -name "alias.txt" | head -n 1)"
if [ -z "$APK" ] || [ -z "$KEYSTORE" ] || [ -z "$KEYPASS" ] || [ -z "$KSPASS" ] || [ -z "$ALIAS" ]; then
echo "One of the following is missing: *.apk, *.keystore, key-pass.txt, ks-pass.txt or alias.txt $i/100"
else
APKS=$(find $PWD -type f -name "*.apk" -not -path "*/\.*")
for i in $APKS ; do
echo "Everything found, start signing..."
BASE="$(dirname $i)"
FILENAME="$(basename $i)"
FILENAME_NO_EXTENSION="${FILENAME%.*}"
OUTFILE="$BASE/$FILENAME_NO_EXTENSION-signed.apk"
/home/pi/android-sdk-linux/build-tools/28.0.0/apksigner sign --key-pass pass:$(cat "$KEYPASS") --ks-pass pass:$(cat "$KSPASS") --ks $KEYSTORE --ks-key-alias $(cat "$ALIAS") --out $OUTFILE $i
echo "Created file:"
echo $OUTFILE
done
echo "Shutdown..."
sudo shutdown -h now
fi
sleep 1;
done;
exit 0