Newer
Older
#!/bin/sh -e
#
# Copyright (c) 2014-2016 Robert Nelson <robertcnelson@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
export LC_ALL=C
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
u_boot_release_x15="v2015.07"
#bone101_git_sha="50e01966e438ddc43b9177ad4e119e5274a0130d"
#contains: rfs_username, release_date
if [ -f /etc/rcn-ee.conf ] ; then
. /etc/rcn-ee.conf
fi
if [ -f /etc/oib.project ] ; then
. /etc/oib.project
fi
export HOME=/home/${rfs_username}
export USER=${rfs_username}
export USERNAME=${rfs_username}
echo "env: [`env`]"
is_this_qemu () {
unset warn_qemu_will_fail
if [ -f /usr/bin/qemu-arm-static ] ; then
warn_qemu_will_fail=1
fi
}
qemu_warning () {
if [ "${warn_qemu_will_fail}" ] ; then
echo "Log: (chroot) Warning, qemu can fail here... (run on real armv7l hardware for production images)"
echo "Log: (chroot): [${qemu_command}]"
fi
}
git_clone () {
mkdir -p ${git_target_dir} || true
qemu_command="git clone ${git_repo} ${git_target_dir} --depth 1 || true"
qemu_warning
git clone ${git_repo} ${git_target_dir} --depth 1 || true
sync
echo "${git_target_dir} : ${git_repo}" >> /opt/source/list.txt
}
git_clone_branch () {
mkdir -p ${git_target_dir} || true
qemu_command="git clone -b ${git_branch} ${git_repo} ${git_target_dir} --depth 1 || true"
qemu_warning
git clone -b ${git_branch} ${git_repo} ${git_target_dir} --depth 1 || true
sync
echo "${git_target_dir} : ${git_repo}" >> /opt/source/list.txt
}
git_clone_full () {
mkdir -p ${git_target_dir} || true
qemu_command="git clone ${git_repo} ${git_target_dir} || true"
qemu_warning
git clone ${git_repo} ${git_target_dir} || true
sync
echo "${git_target_dir} : ${git_repo}" >> /opt/source/list.txt
}
setup_system () {
#For when sed/grep/etc just gets way to complex...
cd /
if [ -f /opt/scripts/mods/debian-add-sbin-usr-sbin-to-default-path.diff ] ; then
if [ -f /usr/bin/patch ] ; then
echo "Patching: /etc/profile"
patch -p1 < /opt/scripts/mods/debian-add-sbin-usr-sbin-to-default-path.diff
fi
fi
Robert Nelson
committed
echo "" >> /etc/securetty
echo "#USB Gadget Serial Port" >> /etc/securetty
echo "ttyGS0" >> /etc/securetty
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
}
setup_desktop () {
if [ -d /etc/X11/ ] ; then
wfile="/etc/X11/xorg.conf"
echo "Patching: ${wfile}"
echo "Section \"Monitor\"" > ${wfile}
echo " Identifier \"Builtin Default Monitor\"" >> ${wfile}
echo "EndSection" >> ${wfile}
echo "" >> ${wfile}
echo "Section \"Device\"" >> ${wfile}
echo " Identifier \"Builtin Default fbdev Device 0\"" >> ${wfile}
# echo " Driver \"modesetting\"" >> ${wfile}
echo " Driver \"fbdev\"" >> ${wfile}
echo "#HWcursor_false Option \"HWcursor\" \"false\"" >> ${wfile}
echo "EndSection" >> ${wfile}
echo "" >> ${wfile}
echo "Section \"Screen\"" >> ${wfile}
echo " Identifier \"Builtin Default fbdev Screen 0\"" >> ${wfile}
echo " Device \"Builtin Default fbdev Device 0\"" >> ${wfile}
echo " Monitor \"Builtin Default Monitor\"" >> ${wfile}
echo " DefaultDepth 16" >> ${wfile}
echo "EndSection" >> ${wfile}
echo "" >> ${wfile}
echo "Section \"ServerLayout\"" >> ${wfile}
echo " Identifier \"Builtin Default Layout\"" >> ${wfile}
echo " Screen \"Builtin Default fbdev Screen 0\"" >> ${wfile}
echo "EndSection" >> ${wfile}
fi
wfile="/etc/lightdm/lightdm.conf"
if [ -f ${wfile} ] ; then
echo "Patching: ${wfile}"
sed -i -e 's:#autologin-user=:autologin-user='$rfs_username':g' ${wfile}
sed -i -e 's:#autologin-session=UNIMPLEMENTED:autologin-session='$rfs_default_desktop':g' ${wfile}
if [ -f /opt/scripts/3rdparty/xinput_calibrator_pointercal.sh ] ; then
sed -i -e 's:#display-setup-script=:display-setup-script=/opt/scripts/3rdparty/xinput_calibrator_pointercal.sh:g' ${wfile}
fi
fi
if [ ! "x${rfs_desktop_background}" = "x" ] ; then
mkdir -p /home/${rfs_username}/.config/ || true
if [ -d /opt/scripts/desktop-defaults/jessie/lxqt/ ] ; then
cp -rv /opt/scripts/desktop-defaults/jessie/lxqt/* /home/${rfs_username}/.config
fi
chown -R ${rfs_username}:${rfs_username} /home/${rfs_username}/.config/
fi
#Disable dpms mode and screen blanking
#Better fix for missing cursor
wfile="/home/${rfs_username}/.xsessionrc"
echo "#!/bin/sh" > ${wfile}
echo "" >> ${wfile}
echo "xset -dpms" >> ${wfile}
echo "xset s off" >> ${wfile}
echo "xsetroot -cursor_name left_ptr" >> ${wfile}
chown -R ${rfs_username}:${rfs_username} ${wfile}
# #Disable LXDE's screensaver on autostart
# if [ -f /etc/xdg/lxsession/LXDE/autostart ] ; then
# sed -i '/xscreensaver/s/^/#/' /etc/xdg/lxsession/LXDE/autostart
# fi
#echo "CAPE=cape-bone-proto" >> /etc/default/capemgr
# #root password is blank, so remove useless application as it requires a password.
# if [ -f /usr/share/applications/gksu.desktop ] ; then
# rm -f /usr/share/applications/gksu.desktop || true
# fi
# #lxterminal doesnt reference .profile by default, so call via loginshell and start bash
# if [ -f /usr/bin/lxterminal ] ; then
# if [ -f /usr/share/applications/lxterminal.desktop ] ; then
# sed -i -e 's:Exec=lxterminal:Exec=lxterminal -l -e bash:g' /usr/share/applications/lxterminal.desktop
# sed -i -e 's:TryExec=lxterminal -l -e bash:TryExec=lxterminal:g' /usr/share/applications/lxterminal.desktop
# fi
# fi
#fix Ping:
#ping: icmp open socket: Operation not permitted
if [ -f /bin/ping ] ; then
if command -v setcap > /dev/null; then
if setcap cap_net_raw+ep /bin/ping cap_net_raw+ep /bin/ping6; then
echo "Setcap worked! Ping(6) is not suid!"
else
echo "Setcap failed on /bin/ping, falling back to setuid" >&2
chmod u+s /bin/ping /bin/ping6
fi
else
echo "Setcap is not installed, falling back to setuid" >&2
chmod u+s /bin/ping /bin/ping6
fi
Robert Nelson
committed
if [ -f /etc/init.d/connman ] ; then
mkdir -p /etc/connman/ || true
wfile="/etc/connman/main.conf"
echo "[General]" > ${wfile}
echo "PreferredTechnologies=ethernet,wifi" >> ${wfile}
echo "SingleConnectedTechnology=false" >> ${wfile}
echo "AllowHostnameUpdates=false" >> ${wfile}
echo "PersistentTetheringMode=true" >> ${wfile}
echo "NetworkInterfaceBlacklist=usb0,SoftAp0" >> ${wfile}
Robert Nelson
committed
mkdir -p /var/lib/connman/ || true
wfile="/var/lib/connman/settings"
echo "[global]" > ${wfile}
echo "OfflineMode=false" >> ${wfile}
echo "" >> ${wfile}
echo "[Wired]" >> ${wfile}
echo "Enable=true" >> ${wfile}
echo "Tethering=false" >> ${wfile}
echo "" >> ${wfile}
echo "[WiFi]" >> ${wfile}
echo "Enable=true" >> ${wfile}
Robert Nelson
committed
echo "Tethering.Identifier=BeagleBone" >> ${wfile}
echo "Tethering.Passphrase=BeagleBone" >> ${wfile}
echo "" >> ${wfile}
echo "[Gadget]" >> ${wfile}
echo "Enable=false" >> ${wfile}
echo "Tethering=false" >> ${wfile}
echo "" >> ${wfile}
echo "[P2P]" >> ${wfile}
echo "Enable=false" >> ${wfile}
echo "Tethering=false" >> ${wfile}
echo "" >> ${wfile}
echo "[Bluetooth]" >> ${wfile}
echo "Enable=true" >> ${wfile}
echo "Tethering=false" >> ${wfile}
Robert Nelson
committed
fi
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
setup_A2DP () {
wfile="/etc/dbus-1/system.d/pulseaudio-system.conf"
line=$(grep -nr org.pulseaudio.Server ${wfile} | awk -F ':' '{print $1}')
#add <allow send_destination="org.bluez"/>
sed -i ''${line}'a <allow send_destination="org.bluez"/>' ${wfile}
wfile="/etc/pulse/system.pa"
line=$(grep -nr module-suspend-on-idle ${wfile} | awk -F ':' '{print $1}')
#remove load-module module-suspend-on-idle
sed -i ''${line}'d' ${wfile}
sed -i '$a ###Baozhu added' ${wfile}
sed -i '$a ### Automatically load driver modules for Bluetooth hardware' ${wfile}
sed -i '$a .ifexists module-bluetooth-policy.so' ${wfile}
sed -i '$a load-module module-bluetooth-policy' ${wfile}
sed -i '$a .endif' ${wfile}
sed -i '$a .ifexists module-bluetooth-discover.so' ${wfile}
sed -i '$a load-module module-bluetooth-discover' ${wfile}
sed -i '$a .endif' ${wfile}
#allow users of pulseaudio to communicate with bluetoothd
wfile="/etc/dbus-1/system.d/bluetooth.conf"
sed -i '$c <!-- allow users of pulseaudio to' ${wfile}
sed -i '$a communicate with bluetoothd -->' ${wfile}
sed -i '$a <policy group="pulse">' ${wfile}
sed -i '$a <allow send_destination="org.bluez"/>' ${wfile}
sed -i '$a </policy>' ${wfile}
sed -i '$a </busconfig>' ${wfile}
#add pulseaudio service
wfile="/lib/systemd/system/pulseaudio.service"
echo "[Unit]" > ${wfile}
echo "Description=Pulse Audio" >> ${wfile}
echo "After=bb-wl18xx-bluetooth.service" >> ${wfile}
echo "[Service]" >> ${wfile}
echo "Type=simple" >> ${wfile}
echo "ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm" >> ${wfile}
echo "[Install]" >> ${wfile}
echo "WantedBy=multi-user.target" >> ${wfile}
systemctl enable pulseaudio.service || true
#add a2dp users to root group
usermod -a -G bluetooth root
usermod -a -G pulse root
usermod -a -G pulse-access root
wfile="/etc/udev/rules.d/10-local.rules"
echo "# Power up bluetooth when hci0 is discovered" > ${wfile}
echo "ACTION=="add", KERNEL=="hci0", RUN+="/bin/hciconfig hci0 up"" >> ${wfile}
}
install_pip_pkgs () {
if [ -f /usr/bin/python ] ; then
wget https://bootstrap.pypa.io/get-pip.py || true
if [ -f get-pip.py ] ; then
python get-pip.py
rm -f get-pip.py || true
if [ -f /usr/local/bin/pip ] ; then
echo "Installing pip packages"
#Fixed in git, however not pushed to pip yet...(use git and install)
#libpython2.7-dev
#pip install Adafruit_BBIO
git_repo="https://github.com/adafruit/adafruit-beaglebone-io-python.git"
git_target_dir="/opt/source/adafruit-beaglebone-io-python"
git_clone
if [ -f ${git_target_dir}/.git/config ] ; then
cd ${git_target_dir}/
python setup.py install
fi
pip install --upgrade PyBBIO
pip install iw_parse
cleanup_npm_cache () {
if [ -d /root/tmp/ ] ; then
rm -rf /root/tmp/ || true
fi
if [ -d /root/.npm ] ; then
rm -rf /root/.npm || true
fi
if [ -f /home/${rfs_username}/.npmrc ] ; then
rm -f /home/${rfs_username}/.npmrc || true
fi
}
install_git_repos () {
if [ -f /usr/bin/jekyll ] ; then
git_repo="https://github.com/beagleboard/bone101"
git_target_dir="/var/lib/cloud9"
if [ "x${bone101_git_sha}" = "x" ] ; then
git_clone
if [ -f ${git_target_dir}/.git/config ] ; then
chown -R ${rfs_username}:${rfs_username} ${git_target_dir}
cd ${git_target_dir}/
if [ ! "x${bone101_git_sha}" = "x" ] ; then
git checkout ${bone101_git_sha} -b tmp-production
fi
echo "jekyll pre-building bone101"
/usr/bin/jekyll build --destination bone101
wfile="/lib/systemd/system/jekyll-autorun.service"
echo "[Unit]" > ${wfile}
echo "Description=jekyll autorun" >> ${wfile}
echo "ConditionPathExists=|/var/lib/cloud9" >> ${wfile}
echo "" >> ${wfile}
echo "[Service]" >> ${wfile}
echo "WorkingDirectory=/var/lib/cloud9" >> ${wfile}
#debian: jekyll 2.2.0 doesn't support --incremental, i'll add this back when i get 3.0.1 working..
# echo "ExecStart=/usr/bin/jekyll build --destination bone101 --watch --incremental" >> ${wfile}
echo "ExecStart=/usr/bin/jekyll build --destination bone101 --watch" >> ${wfile}
echo "SyslogIdentifier=jekyll-autorun" >> ${wfile}
echo "CPUAccounting=true" >> ${wfile}
echo "CPUQuota=10%" >> ${wfile}
echo "MemoryAccounting=true" >> ${wfile}
echo "MemoryLimit=50M" >> ${wfile}
echo "" >> ${wfile}
echo "[Install]" >> ${wfile}
echo "WantedBy=multi-user.target" >> ${wfile}
systemctl enable jekyll-autorun.service || true
if [ -d /etc/apache2/ ] ; then
#bone101 takes over port 80, so shove apache/etc to 8080:
if [ -f /etc/apache2/ports.conf ] ; then
sed -i -e 's:80:8080:g' /etc/apache2/ports.conf
if [ -f /etc/apache2/sites-enabled/000-default ] ; then
sed -i -e 's:80:8080:g' /etc/apache2/sites-enabled/000-default
if [ -f /var/www/html/index.html ] ; then
rm -rf /var/www/html/index.html || true
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
fi
fi
fi
git_repo="https://github.com/prpplague/Userspace-Arduino"
git_target_dir="/opt/source/Userspace-Arduino"
git_clone
git_repo="https://github.com/cdsteinkuehler/beaglebone-universal-io.git"
git_target_dir="/opt/source/beaglebone-universal-io"
git_clone
if [ -f ${git_target_dir}/.git/config ] ; then
if [ -f ${git_target_dir}/config-pin ] ; then
ln -s ${git_target_dir}/config-pin /usr/local/bin/
fi
fi
git_repo="https://github.com/strahlex/BBIOConfig.git"
git_target_dir="/opt/source/BBIOConfig"
git_clone
git_repo="https://github.com/prpplague/fb-test-app.git"
git_target_dir="/opt/source/fb-test-app"
git_clone
if [ -f ${git_target_dir}/.git/config ] ; then
cd ${git_target_dir}/
if [ -f /usr/bin/make ] ; then
make
fi
cd /
fi
#am335x-pru-package
if [ -f /usr/include/prussdrv.h ] ; then
git_repo="https://github.com/biocode3D/prufh.git"
git_target_dir="/opt/source/prufh"
git_clone
if [ -f ${git_target_dir}/.git/config ] ; then
cd ${git_target_dir}/
if [ -f /usr/bin/make ] ; then
make LIBDIR_APP_LOADER=/usr/lib/ INCDIR_APP_LOADER=/usr/include
fi
cd /
fi
fi
is_kernel=$(echo ${repo_rcnee_pkg_version} | grep 4.1. || true)
if [ ! "x${is_kernel}" = "x" ] ; then
git_branch="4.1-ti"
else
is_kernel=$(echo ${repo_rcnee_pkg_version} | grep 4.4. || true)
if [ ! "x${is_kernel}" = "x" ] ; then
git_branch="4.4-ti"
fi
fi
git_repo="https://github.com/RobertCNelson/dtb-rebuilder.git"
git_target_dir="/opt/source/dtb-${git_branch}"
git_clone_branch
git_repo="https://github.com/beagleboard/bb.org-overlays"
git_target_dir="/opt/source/bb.org-overlays"
git_clone
if [ -f ${git_target_dir}/.git/config ] ; then
cd ${git_target_dir}/
if [ ! "x${repo_rcnee_pkg_version}" = "x" ] ; then
is_kernel=$(echo ${repo_rcnee_pkg_version} | grep 3.8.13 || true)
if [ "x${is_kernel}" = "x" ] ; then
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
if [ -f /usr/bin/make ] ; then
make
make install
update-initramfs -u -k ${repo_rcnee_pkg_version}
make clean
fi
fi
fi
fi
git_repo="https://github.com/ungureanuvladvictor/BBBlfs"
git_target_dir="/opt/source/BBBlfs"
git_clone
if [ -f ${git_target_dir}/.git/config ] ; then
cd ${git_target_dir}/
if [ -f /usr/bin/make ] ; then
./autogen.sh
./configure
make
fi
fi
#am335x-pru-package
if [ -f /usr/include/prussdrv.h ] ; then
git_repo="git://git.ti.com/pru-software-support-package/pru-software-support-package.git"
git_target_dir="/opt/source/pru-software-support-package"
git_clone
fi
}
install_build_pkgs () {
cd /opt/
cd /
}
other_source_links () {
rcn_https="https://rcn-ee.com/repos/git/u-boot-patches"
mkdir -p /opt/source/u-boot_${u_boot_release}/
wget --directory-prefix="/opt/source/u-boot_${u_boot_release}/" ${rcn_https}/${u_boot_release}/0001-omap3_beagle-uEnv.txt-bootz-n-fixes.patch
wget --directory-prefix="/opt/source/u-boot_${u_boot_release}/" ${rcn_https}/${u_boot_release}/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
mkdir -p /opt/source/u-boot_${u_boot_release_x15}/
wget --directory-prefix="/opt/source/u-boot_${u_boot_release_x15}/" ${rcn_https}/${u_boot_release_x15}/0001-beagle_x15-uEnv.txt-bootz-n-fixes.patch
echo "u-boot_${u_boot_release} : /opt/source/u-boot_${u_boot_release}" >> /opt/source/list.txt
echo "u-boot_${u_boot_release_x15} : /opt/source/u-boot_${u_boot_release_x15}" >> /opt/source/list.txt
chown -R ${rfs_username}:${rfs_username} /opt/source/
}
unsecure_root () {
root_password=$(cat /etc/shadow | grep root | awk -F ':' '{print $2}')
sed -i -e 's:'$root_password'::g' /etc/shadow
if [ -f /etc/ssh/sshd_config ] ; then
#Make ssh root@beaglebone work..
sed -i -e 's:PermitEmptyPasswords no:PermitEmptyPasswords yes:g' /etc/ssh/sshd_config
sed -i -e 's:UsePAM yes:UsePAM no:g' /etc/ssh/sshd_config
#Starting with Jessie:
sed -i -e 's:PermitRootLogin without-password:PermitRootLogin yes:g' /etc/ssh/sshd_config
fi
if [ -f /etc/sudoers ] ; then
#Don't require password for sudo access
echo "${rfs_username} ALL=NOPASSWD: ALL" >>/etc/sudoers
fi
}
is_this_qemu
setup_system
setup_desktop
install_pip_pkgs
if [ -f /usr/bin/git ] ; then
git config --global user.email "${rfs_username}@example.com"
git config --global user.name "${rfs_username}"
install_git_repos
git config --global --unset-all user.email
git config --global --unset-all user.name
fi
#install_build_pkgs
other_source_links
unsecure_root
#