-
Notifications
You must be signed in to change notification settings - Fork 17
/
raspoppyfication.sh
executable file
·129 lines (121 loc) · 3.51 KB
/
raspoppyfication.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
exec > >(tee /home/pi/log_raspoppy_$(date +%F_%H-%M).txt) 2>&1
set -e
program_name=$0
function usage() {
echo "Poppy robot installation script"
echo ""
echo "usage: $program_name"
echo " or: $program_name [--argument=argument-value]"
echo ""
echo "Arguments:"
echo " --creature Set the robot type (default: poppy-ergo-jr)"
echo " --username Set the Poppy user name (default: poppy)"
echo " --password Set password for the Poppy user (default: poppy)"
echo " --hostname Set the robot hostname (default: poppy)"
echo " --branch Install from a given git branch (default: master)"
echo " --reboot Reboot the system after installation"
echo " -?|--help Show this help"
echo ""
echo "Example usage:"
echo " ./raspoppyfication.sh"
echo " ./raspoppyfication.sh --creature=poppy-ergo-starter --hostname=roboto"
echo " ./raspoppyfication.sh --help"
exit
}
for i in "$@"
do
case $i in
-?|--help)
usage
exit
shift
;;
--creature=*)
poppy_creature="${i#*=}"
shift
;;
--username=*)
poppy_username="${i#*=}"
shift
;;
--password=*)
poppy_password="${i#*=}"
shift
;;
--hostname=*)
poppy_hostname="${i#*=}"
shift
;;
--branch=*)
git_branch="${i#*=}"
shift
;;
-s|--reboot)
reboot_after_install=1
shift
;;
esac
done
poppy_creature=${poppy_creature:-"poppy-ergo-jr"}
poppy_username=${poppy_username:-"poppy"}
poppy_password=${poppy_password:-"poppy"}
poppy_hostname=${poppy_hostname:-"poppy"}
git_branch=${git_branch:-"master"}
reboot_after_install=${reboot_after_install:-0}
# scratch_installation
raspoppy_branch="master"
url_root="https://raw.githubusercontent.com/poppy-project/raspoppy/$raspoppy_branch"
cd /tmp || exit
echo -e " "
echo -e "\e[33m *********************************** \e[0m"
echo -e "\e[33m **** RasPoppyfication Starting **** \e[0m"
echo -e "\e[33m *********************************** \e[0m"
echo -e " "
TIME=$(date)
echo -e "\e[33m -- $TIME -- \e[0m"
echo -e " "
TIME=$(date "+%H:%M:%S")
echo -e "\e[33m ** Setting System ** \e[0m -- $TIME --"
echo -e " "
wget "$url_root/setup-system.sh"
bash setup-system.sh "$poppy_username" "$poppy_password" "$poppy_creature" "$git_branch"
echo -e " "
TIME=$(date "+%H:%M:%S")
echo -e "\e[33m ** Setting Python ** \e[0m -- $TIME --"
echo -e " "
wget "$url_root/setup-python.sh"
sudo -u "$poppy_username" bash setup-python.sh "$git_branch"
echo -e " "
TIME=$(date "+%H:%M:%S")
echo -e "\e[33m ** Setting Poppy ** \e[0m -- $TIME --"
echo -e " "
wget "$url_root/setup-poppy.sh"
sudo -u "$poppy_username" bash -i setup-poppy.sh "$poppy_creature" "$poppy_hostname" "$git_branch"
echo -e " "
TIME=$(date "+%H:%M:%S")
echo -e "\e[33m ** Setting ROS ** \e[0m -- $TIME --"
echo -e " "
wget "$url_root/setup-ros.sh"
sudo -u "$poppy_username" bash setup-ros.sh "$poppy_creature" "master"
echo -e " "
TIME=$(date "+%H:%M:%S")
echo -e "\e[33m ** Setting Network ** \e[0m -- $TIME --"
echo -e " "
echo -e "\e[33m setup-hotspot \e[0m"
wget "$url_root/setup-hotspot.sh"
bash setup-hotspot.sh "$git_branch"
echo -e "\e[33m change-hostname to \e[4m$poppy_hostname\e[0m"
sudo raspi-config --change-hostname "$poppy_hostname"
echo -e " "
TIME=$(date)
echo -e "\e[33m -- $TIME -- \e[0m"
echo -e " "
echo -e "\e[33m *********************************** \e[0m"
echo -e "\e[33m **** RasPoppyfication Complete **** \e[0m"
echo -e "\e[33m *********************************** \e[0m"
echo -e " "
if [ $reboot_after_install -eq 1 ]; then
echo -e "\e[33m ** REBOOT ** \e[0m"
reboot
fi