Skip to content

Commit b417c10

Browse files
committed
Add a check to see if ADB exits.
Kill the adb server only if present
1 parent 2633956 commit b417c10

File tree

1 file changed

+46
-14
lines changed

1 file changed

+46
-14
lines changed

create_android_rules.sh

100644100755
Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
#!/bin/bash
22

33

4+
5+
exists()
6+
{
7+
if command -v $1 &>/dev/null
8+
then
9+
# echo " Yes, command :$1: was found."
10+
return 0
11+
else
12+
# echo " No, command :$1: was NOT found."
13+
return 1
14+
fi
15+
}
16+
17+
killadbserver(){
18+
19+
echo "Adb found, killing the adb server"
20+
adb kill-server
21+
22+
echo
23+
echo "*******************************************************"
24+
echo "Please unplug and replug any currently connected devices"
25+
echo "Press enter to continue"
26+
read pause
27+
28+
echo ""
29+
echo "*******************************************************"
30+
31+
adb devices
32+
33+
34+
}
35+
36+
437
echo ""
538
echo "*******************************************************"
639
echo "Add device permisions to the udev rules by LinuxMotion"
@@ -12,24 +45,23 @@ then
1245
echo "Restarting udev to read the new rules"
1346
sudo service udev restart
1447

15-
echo
16-
echo "Killing the adb server"
1748

18-
adb kill-server
49+
else
1950

20-
echo
21-
echo "*******************************************************"
22-
echo "Please unplug and replug any currently connected devices"
23-
echo "Press enter to continue"
24-
read pause
51+
echo "Your files was not created, please run again with sudo"
2552

26-
echo ""
27-
echo "*******************************************************"
53+
fi
2854

29-
adb devices
55+
adbexists=&(exists adb)
56+
echo $x
3057

31-
else
58+
if [ $adbexists-eq0 ]
59+
then
60+
61+
killadbserver
62+
63+
else
64+
echo "ADB is not in your path, but the script was created"
65+
fi
3266

33-
echo "Your files was not created, please run again with sudo"
34-
fi
3567

0 commit comments

Comments
 (0)