deploy-busunit-interactive 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2019 Clementine Computing LLC.
  4. #
  5. # This file is part of PopuFare.
  6. #
  7. # PopuFare is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # PopuFare is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
  19. #
  20. GITURL="https://tree.clementinecomputing.com/clementinecomputing/popufare"
  21. echo ""
  22. echo ' _____ __ '
  23. echo ' | __ \ / _| '
  24. echo ' | |__) |__ _ __ _ _| |_ __ _ _ __ ___ '
  25. echo ' | ___/ _ \| '"'"'_ \| | | | _/ _` | '"'"'__/ _ \'
  26. echo ' | | | (_) | |_) | |_| | || (_| | | | __/'
  27. echo ' |_| \___/| .__/ \__,_|_| \__,_|_| \___|'
  28. echo ' | | '
  29. echo ' |_| '
  30. echo ""
  31. echo "This script attempts to setup a default installation of Popufare on a busunit (a Raspberry Pi, say)"
  32. echo "by setting up and configuring the system."
  33. echo ""
  34. echo "THIS SCRIPT CHANGES SYSTEM WIDE PARAMETERS AND COULD HAVE SERIOUS CONSEQUENCES TO THE MACHINE IT'S RUN"
  35. echo "ON."
  36. echo ""
  37. echo "As such, this scripts needs root access (via sudo)."
  38. echo "This script is meant to be a 'helper' script and isn't meant to be all encompassing. Among other things,"
  39. echo "this script will:"
  40. echo ""
  41. echo " * setup a 'bus' user and group"
  42. echo " * add the 'pi' user to the 'bus' group"
  43. echo " * clone the Popufare repo, build it's binaries and install them in the '/home/bus' user directory"
  44. echo " * copy over appropriate config files to the appropriate locations in the '/hom/ebus' user directory"
  45. echo " * setup ssh keys and credentials"
  46. echo " * setup the PPP config files"
  47. echo " * alter /boot/config.txt and /etc/modules to enable serial and sound setup"
  48. echo " * setup a 'kiosk' service for the front end DIU"
  49. echo " * setup 'rc.local' to start and monitor bus Popufare services on startup"
  50. echo " * setup legacy data directories in '/mnt/data2'"
  51. echo ""
  52. echo "Most parameters have options to prompt the user for installation."
  53. echo ""
  54. echo "This script should be used with caution and as a helper for an installation rather than a 'turn key' soluation."
  55. echo "For example, the ssh keys default to the UNSECURE 'snakeoil' default keys provided the repo for easy setup and"
  56. echo "MUST BE CHANGED for a production installation."
  57. echo ""
  58. echo "In addition, the host and other config file options should be set on a per installation basis, as should the custom"
  59. echo "DIU interface, rules, drivers.txt entries, etc."
  60. echo ""
  61. echo "This script should help in getting a Raspberry Pi ready for use with Popufare but should be thought of also as a"
  62. echo "record of what relevant files there are to change and where to look."
  63. echo ""
  64. echo "As Popufare matures, this installation script or something similar can accomodate a more seamless installation but"
  65. echo "this is what is provided now."
  66. echo ""
  67. echo "Popufare is free software so please feel free to contribute at:"
  68. echo ""
  69. echo " https://tree.clementinecomputing.com/clementinecomputing/popufare"
  70. echo ""
  71. echo -n "Hit return to continue [ok]: "
  72. read hitreturn
  73. DATESTR=`date '+%Y%m%d%H%M%S'`
  74. ###### basic sanity checks to make sure we're installing on a Raspberry Pi
  75. ######
  76. if [[ ! -e /etc/os-release ]] ; then
  77. echo -n "Are you sure you want to install? '/etc/os-release' does not exist and this system might not be a Raspberry Pi. Continue? [y/N]: "
  78. read fnfok
  79. if [[ ! "$fnfok" =~ ^[yY]$ ]] ; then
  80. echo "cancelling installalation"
  81. echo ""
  82. exit
  83. else
  84. echo "ok, continuing installation..."
  85. fi
  86. else
  87. grep -P '^PRETTY_NAME="Raspbian' /etc/os-release 2>&1 > /dev/null
  88. r=$?
  89. if [[ $r != 0 ]] ; then
  90. echo -n "Raspbian not detected in '/etc/os-release'. This might not be Raspberry Pi. Continue with installation? [y/N]: "
  91. read okcontinue
  92. if [[ ! "$okcontinue" =~ ^[yY]$ ]] ; then
  93. echo "cancelling installation"
  94. echo ""
  95. exit
  96. else
  97. echo "ok, continuing installation..."
  98. fi
  99. fi
  100. fi
  101. echo ""
  102. ######
  103. ######
  104. echo -n "Install package dependencies? [Y/n]: "
  105. read adddeps
  106. if [[ "$adddeps" =~ ^[yY]?$ ]]; then
  107. deps="espeak mplayer git"
  108. echo ""
  109. echo " Installing: $deps"
  110. sudo apt-get update
  111. sudo apt-get install -y $deps
  112. echo ""
  113. echo -n " Remove unused packages (free up space)? [Y/n]: "
  114. read remunused
  115. if [[ "$remunused" =~ ^[yY]?$ ]]; then
  116. remdeps="libreoffice libreoffice-base-core libreoffice-common \
  117. libreoffice-core libreoffice-help-common libreoffice-help-en-gb \
  118. libreoffice-help-en-us libreoffice-l10n-en-gb \
  119. libreoffice-style-colibre libreoffice-style-tango"
  120. echo ""
  121. echo " Removing: $remdeps"
  122. sudo apt-get remove -y $remdeps
  123. sudo apt-get autoremove -y --purge
  124. echo ""
  125. fi
  126. fi
  127. echo ""
  128. ######
  129. ######
  130. echo -n "Create 'bus' user? [Y/n]: "
  131. read createbususer
  132. if [[ "$createbususer" =~ ^[yY]?$ ]]; then
  133. echo "... creating 'bus' user and group"
  134. sudo adduser bus
  135. sudo usermod -a -G dialout bus
  136. fi
  137. echo ""
  138. echo -n "Add 'pi' to 'bus' group? [Y/n]: "
  139. read addpibus
  140. if [[ "$addpibus" =~ ^[yY]$ ]]; then
  141. echo "... add 'pi' to 'bus' group"
  142. sudo usermod -a -G bus pi
  143. fi
  144. echo ""
  145. echo "Creating /home/bus/(bin|database|config) with group write permissions"
  146. sudo mkdir -p /home/bus/bin
  147. sudo mkdir -p /home/bus/database
  148. sudo mkdir -p /home/bus/config
  149. sudo chown -R bus:bus /home/bus/bin
  150. sudo chown -R bus:bus /home/bus/database
  151. sudo chown -R bus:bus /home/bus/config
  152. sudo chmod -R g+w /home/bus/bin
  153. sudo chmod -R g+w /home/bus/database
  154. sudo chmod -R g+w /home/bus/config
  155. echo ""
  156. echo -n "Repo path (hit return to automatically clone the repo and use that) []: "
  157. read repolocation
  158. tmpdir=""
  159. if [[ "$repolocation" == "" ]] ; then
  160. tmpdir=`mktemp -d`
  161. repolocation="$tmpdir/popufare"
  162. pushd $tmpdir
  163. git clone "$GITURL"
  164. popd
  165. fi
  166. echo "Setting up binaries..."
  167. bd=/home/bus/popufare/busunit
  168. d=/home/bus/popufare/busunit/bin/native
  169. diudir=/home/bus/popufare/busunit/DIUv2
  170. tc=/home/bus/popufare/busunit/testing/config
  171. sudo cp -R $repolocation /home/bus
  172. sudo chown -R bus:bus /home/bus/popufare
  173. sudo bash -c " su - bus -c ' cd /home/bus/popufare/busunit ; ./build_all.sh native ; ' "
  174. sudo bash -c " cd /home/bus/bin ; cp -fRL $d/avls . ; cp -fRL $d/billdb . ; cp -fRL $d/client_supervisor . ; cp -fRL $d/debug_client . ; cp -fRL $d/diu_minder . ; cp -fRL $d/ipc_server . "
  175. sudo bash -c " cd /home/bus/bin ; cp -fRL $d/paddlemgr . ; cp -fRL $d/passdb . ; cp -fRL $d/piu_minder . ; cp -fRL $d/send_billing_record . ; cp -fRL $d/send_magstripe . "
  176. sudo bash -c " cd /home/bus/bin ; cp -fRL $d/gps_minder . "
  177. sudo bash -c " cd /home/bus/bin ; cp -fRL $bd/DIUv2/diu_kiosk . "
  178. sudo bash -c " cd /home/bus/bin ; cp -fRL $bd/scripts/init_bus.sh . ; cp -fRL $bd/scripts/update_loop.sh . ; cp -fRL $bd/scripts/setup-serial.py . ; cp -fRL $bd/scripts/get_net_ids.sh . "
  179. sudo bash -c " cd /home/bus/bin ; cp -fRL $bd/scripts/connection_tether.sh . ; cp -fRL $bd/scripts/reset-gps.py ./reset-gps "
  180. sudo bash -c " cd /home/bus/bin ; cp -fRL $bd/scripts/apply_update.sh . ; cp -fRL $bd/scripts/apply_update_legacy.sh . ; cp -fRL $bd/scripts/apply_update_popufare.sh . "
  181. sudo bash -c " cd /home/bus/bin ; cp -fRL $bd/scripts/fix_pkg_perm.sh . "
  182. sudo bash -c " cd /home/bus/config ; cp -fRL $diudir/html . ; "
  183. sudo bash -c " cd /home/bus/config ; cp $bd/passdb/init.scm . ; cp $bd/passdb/rfid_patterns.txt . ; cp $bd/avls/avls_freq.txt . "
  184. sudo bash -c " cd /home/bus/config ; cp $bd/passdb/init.scm . ; cp $bd/passdb/rfid_patterns.txt . ; cp $bd/avls/avls_freq.txt . "
  185. sudo bash -c " cd /home/bus/config ; cp $tc/equipnum.txt . ; cp $tc/serial.txt serial_num "
  186. sudo bash -c " rm -f /home/bus/bin/common_values.sh ; cp $bd/scripts/common_values.sh /home/bus/bin "
  187. ## server endpoint config files
  188. ##
  189. ## sync_server_desc, sync_target, server_list, syn_port
  190. sudo cp /home/bus/popufare/busunit/testing/config/config.tgz.checksum /home/bus/config/config.tgz.checksum
  191. sudo cp /home/bus/popufare/busunit/testing/config/config.tgz.version /home/bus/config/config.tgz.version
  192. sudo cp /home/bus/popufare/busunit/testing/config/firmware.tgz.checksum /home/bus/config/firmware.tgz.checksum
  193. sudo cp /home/bus/popufare/busunit/testing/config/firmware.tgz.version /home/bus/config/firmware.tgz.version
  194. sudo cp /home/bus/popufare/busunit/testing/config/package.tgz.checksum /home/bus/config/package.tgz.checksum
  195. sudo cp /home/bus/popufare/busunit/testing/config/package.tgz.version /home/bus/config/package.tgz.version
  196. sudo mkdir -p /home/bus/config/server
  197. echo ""
  198. ##### paddle setup
  199. #####
  200. echo -n "Setup paddles? [Y/n]: "
  201. read setuppaddles
  202. if [[ "$setuppaddles" =~ ^[yY]?$ ]] ; then
  203. echo -n "Paddle location? (blank for default testing paddles) []: "
  204. read paddlocation
  205. if [[ "$paddlelocation" == "" ]] ; then
  206. paddlelocation=$bd/busunit/testing
  207. fi
  208. echo "Using '$paddlelocation/*.paddle'..."
  209. sudo bash -c " cd /home/bus/config ; cp $bd/testing/*.paddle . "
  210. fi
  211. echo ""
  212. ##### rules setup
  213. #####
  214. echo -n "Setup rules? [Y/n]: "
  215. read setuprules
  216. if [[ "$setuprules" =~ ^[yY]?$ ]] ; then
  217. echo -n "Rule file? (blank for default testing rules) []: "
  218. read rulelocation
  219. if [[ "$rulelocation" == "" ]] ; then
  220. rulelocation=$bd/testing/rules-ORG.scm
  221. fi
  222. echo "Setting up rules from '$rulelocation'..."
  223. sudo bash -c " cd /home/bus/config ; cp $rulelocation rules.scm "
  224. fi
  225. echo ""
  226. ##### equipment number setup
  227. #####
  228. echo -n "Equipment number? [9999]: "
  229. read equipnum
  230. if [[ "$equipnum" == "" ]] ; then
  231. equipnum=9999
  232. fi
  233. echo "Setting equipment number to '$equipnum'..."
  234. sudo bash -c " echo $equipnum > /home/bus/config/equipnum.txt "
  235. echo ""
  236. ##### key setup
  237. #####
  238. echo -n "Setup secure communcation setup? [Y/n]: "
  239. read tunnelsetup
  240. if [[ "$tunnelsetup" =~ ^[yY]?$ ]] ; then
  241. echo -n " 'id_rsa' private key location? (default to snakeoil) []: "
  242. read keylocation
  243. if [[ "$keylocation" == "" ]] ; then
  244. keylocation=/home/bus/popufare/server/docker/snakeoil_id_rsa
  245. fi
  246. echo " Using '$keylocation' for private key..."
  247. sudo mkdir -p /home/bus/.ssh
  248. sudo chown -R bus:bus /home/bus/.ssh
  249. sudo cp $keylocation /home/bus/.ssh/id_rsa_bus
  250. sudo chown bus:bus /home/bus/.ssh/id_rsa_bus
  251. sudo chmod 400 /home/bus/.ssh/id_rsa_bus
  252. echo ""
  253. echo -n " Tunnel port? [6055]: "
  254. read tunnelport
  255. if [[ "$tunnelport" == "" ]] ; then
  256. tunnelport=6055
  257. fi
  258. echo ""
  259. echo -n " Tunnel user and host? [bus@example.com]: "
  260. read tunnelhost
  261. if [[ "$tunnelhost" == "" ]] ; then
  262. tunnelhost='bus@example.com'
  263. fi
  264. echo ""
  265. echo -n " Adding values to '/home/bus/bin/common_values.sh'..."
  266. sed -i 's;^SSH_DEFAULT_TARGET=;#SSH_DEFAULT_TARGET=;g' /home/bus/bin/common_values.sh
  267. sed -i 's;^SSH_DEFAULT_PORT=;#SSH_DEFAULT_PORT=;g' /home/bus/bin/common_values.sh
  268. sed -i 's;^SSH_DEFAULT_IDENTITY=;#SSH_DEFAULT_IDENTITY=;g' /home/bus/bin/common_values.sh
  269. sed -i 's;^SSH_TARGET=;#SSH_TARGET=;g' /home/bus/bin/common_values.sh
  270. sed -i 's;^SSH_PORT=;#SSH_PORT=;g' /home/bus/bin/common_values.sh
  271. sed -i 's;^SSH_IDENTITY=;#SSH_IDENTITY=;g' /home/bus/bin/common_values.sh
  272. echo 'SSH_DEFAULT_TARGET="'"$tunnelhost"'"' >> /home/bus/bin/common_values.sh
  273. echo 'SSH_DEFAULT_PORT="'"$tunnelport"'"' >> /home/bus/bin/common_values.sh
  274. echo 'SSH_DEFAULT_IDENTITY="/home/bus/.ssh/id_rsa_bus"' >> /home/bus/bin/common_values.sh
  275. echo '' >> /home/bus/bin/common_values.sh
  276. echo 'SSH_TARGET="$SSH_DEFAULT_TARGET"' >> /home/bus/bin/common_values.sh
  277. echo 'SSH_PORT="$SSH_DEFAULT_PORT"' >> /home/bus/bin/common_values.sh
  278. echo 'SSH_IDENTITY="$SSH_DEFAULT_IDENTITY"' >> /home/bus/bin/common_values.sh
  279. echo ""
  280. fi
  281. echo ""
  282. ##### drivers setup
  283. #####
  284. echo -n "'drivers.txt' location? (default to test) []: "
  285. read driverlocation
  286. if [[ "$driverlocation" == "" ]] ; then
  287. driverlocation=/home/bus/popufare/busunit/DIUv2/drivers.txt
  288. fi
  289. echo "Using '$driverlocation' for drivers.txt ..."
  290. sudo cp $driverlocation /home/bus/config
  291. echo ""
  292. ##### setup fona ppp
  293. #####
  294. echo -n "Setup FONA ppp files? [Y/n]: "
  295. read setupfona
  296. if [[ "$setupfona" =~ ^[yY]?$ ]] ; then
  297. echo " Creating /etc/ppp/peers/ and /etc/chatscripts/"
  298. sudo mkdir -p /etc/ppp/peers/
  299. sudo mkdir -p /etc/chatscripts/
  300. echo " /home/bus/popufare/busunit/ppp-dialer/etc/ppp/peers/fona -> /etc/ppp/peers/gprs"
  301. echo " /home/bus/popufare/busunit/ppp-dialer/etc/chatscripts/gprs -> /etc/chatscripts/gprs"
  302. sudo cp /home/bus/popufare/busunit/ppp-dialer/etc/ppp/peers/fona /etc/ppp/peers/gprs
  303. sudo cp /home/bus/popufare/busunit/ppp-dialer/etc/chatscripts/gprs /etc/chatscripts/gprs
  304. echo ""
  305. fi
  306. #echo -n "Setup FONA to connect at startup? [Y/n]: "
  307. #read fonanetwork
  308. #
  309. #if [[ "$fonanetwork" =~ ^[yY]?$ ]] ; then
  310. # echo " Creating '/etc/network/interfaces.d/fona'..."
  311. # sudo echo 'auto fona' > /etc/network/interfaces.d/fona
  312. # sudo echo 'iface fona inet ppp' >> /etc/network/interfaces.d/fona
  313. # sudo echo ' provider fona' >> /etc/network/interfaces.d/fona
  314. #fi
  315. ##### Setup config.txt
  316. #####
  317. echo -n "Setup '/boot/config.txt'? (Note this could have serious consequences, use with caution) [y/N]: "
  318. read setupconfig
  319. if [[ "$setupconfig" =~ ^[yY]$ ]] ; then
  320. tmpfn=`mktemp`
  321. bfn=`basename $tmpfn`
  322. echo " Saving 'config.txt' to /root/$bfn"
  323. sudo cp /boot/config.txt $tmpfn
  324. sudo mv $tmpfn /root/$bfn
  325. echo " adding> enable_uart=1"
  326. sudo sed -i 's;^enable_uart=;#enable_uart=;g' /boot/config.txt
  327. sudo bash -c 'echo "enable_uart=1" >> /boot/config.txt'
  328. echo " adding> dtoverlay=pi3-disable-bt"
  329. sudo sed -i 's;^dtoverlay=pi3-disable-bt;#dtoverlay=pi3-disable-bt;g' /boot/config.txt
  330. sudo bash -c 'echo "dtoverlay=pi3-disable-bt" >> /boot/config.txt'
  331. echo " adding> dtoverlay=pi3-disable-wifi"
  332. sudo sed -i 's;^dtoverlay=pi3-disable-wifi;#dtoverlay=pi3-disable-wifi;g' /boot/config.txt
  333. sudo bash -c 'echo "dtoverlay=pi3-disable-wifi" >> /boot/config.txt'
  334. fi
  335. echo ""
  336. ##### Setup sound in modules file
  337. #####
  338. echo -n "Setup sound (alter '/etc/modules')? [y/N]: "
  339. read setupsound
  340. if [[ "$setupsound" =~ ^[yY]$ ]] ; then
  341. tmpfn=`mktemp`
  342. bfn=`basename $tmpfn`
  343. echo " Saving 'modules' to /root/$bfn"
  344. sudo cp /etc/modules $tmpfn
  345. sudo mv $tmpfn /root/$bfn
  346. sudo sed -i 's;^snd-bcm2835;#snd-bcm2835;g' /etc/modules
  347. echo ' adding> snd-bcm2835'
  348. sudo bash -c 'echo "snd-bcm2835" >> /etc/modules'
  349. # disabled for now. Force audio to go through 3.5mm jack from 'raspi-config'.
  350. #
  351. # ...
  352. # trying to mitigate the 'first two seconds cutoff of audio' problem
  353. # https://github.com/alexa-pi/AlexaPi/wiki/Devices#raspberry-pi
  354. #
  355. #tfn=`mktemp`
  356. #echo '@reboot vcgencmd force_audio hdmi 1' > $tfn
  357. #echo "adding `cat $tfn`"
  358. #sudo crontab $tfn
  359. #rm $tfn
  360. fi
  361. ##### Change hostname
  362. #####
  363. echo -n "Change hostname? [y/N]: "
  364. read changehostname
  365. if [[ "$changehostname" =~ ^[yY]$ ]] ; then
  366. echo -n " New hostname [popufaredev]: "
  367. read newhostname
  368. if [[ "$newhostname" == "" ]] ; then
  369. newhostname=popufaredev
  370. fi
  371. echo " Saving /etc/hostname to /root/hostname.$DATESTR"
  372. sudo cp /etc/hostname /root/hostname.$DATESTR
  373. sudo bash -c "echo '$newhostname' > /etc/hostname"
  374. tfn=`mktemp`
  375. echo -e '127.0.0.1\tlocalhost' > $tfn
  376. echo -e '::1\t\tlocalhost ip6-localhost ip6-loopback' >> $tfn
  377. echo -e 'ff02::1\t\tip6-allnodes' >> $tfn
  378. echo -e 'ff02::2\t\tip6-allrouters' >> $tfn
  379. echo '' >> $tfn
  380. echo -e '127.0.1.1\t'"$newhostname" >> $tfn
  381. echo " Saving /etc/hosts to /root/hosts.$DATESTR"
  382. sudo cp /etc/hosts /root/hosts.$DATESTR
  383. echo " Creating new /etc/hosts file"
  384. sudo mv $tfn /etc/hosts
  385. sudo chmod 644 /etc/hosts
  386. fi
  387. ##### Setup kiosk
  388. #####
  389. echo -n "Setup kiosk service? [Y/n]: "
  390. read setupkiosk
  391. if [[ "$setupkiosk" =~ ^[yY]?$ ]] ; then
  392. echo " /home/bus/popufare/busunit/rootfs/etc/systemd/system/kiosk.service -> /lib/systemd/system/kiosk.service"
  393. sudo cp /home/bus/popufare/busunit/rootfs/etc/systemd/system/kiosk.service /lib/systemd/system/kiosk.service
  394. echo " enabling kiosk.service ('systemctl enable kiosk.service')"
  395. sudo systemctl enable kiosk.service
  396. ## Changing hostname will screw up chromium if it's already been run under a different
  397. ## hostname. Remove the files that cause the problems so Chromium can run without
  398. ## issue.
  399. ##
  400. echo " removing chromium 'Singleton*' files"
  401. sudo rm -rf /home/bus/.config/chromium/Singleton*
  402. fi
  403. echo ""
  404. ##### Setup startup
  405. #####
  406. echo -n "Setup startup 'rc.local'? [Y/n]: "
  407. read setupstartup
  408. if [[ "$setupstartup" =~ ^[yY]?$ ]] ; then
  409. tmpfn=`mktemp`
  410. bfn=`basename $tmpfn`
  411. echo " saving /etc/rc.local to /root/$bfn"
  412. sudo cp /etc/rc.local $tmpfn
  413. sudo mv $tmpfn /root/$bfn
  414. echo " /home/bus/popufare/busunit/rootfs/etc/rc.local -> /etc/rc.local"
  415. sudo cp /home/bus/popufare/busunit/rootfs/etc/rc.local /etc/rc.local
  416. fi
  417. echo ""
  418. ##### setup legacy data directories
  419. #####
  420. echo -n "Setup legacy data directories? [y/N]: "
  421. read setuplegacy
  422. if [[ "$setuplegacy" =~ ^[yY]$ ]] ; then
  423. sudo mkdir -p /mnt/data
  424. sudo mkdir -p /mnt/data2
  425. sudo chown -R bus:bus /mnt/data
  426. sudo chown -R bus:bus /mnt/data2
  427. fi
  428. #####
  429. #####
  430. ##### final permissions setup
  431. #####
  432. echo "Setting up final permission for /home/bus/(bin|database|config)"
  433. sudo chown -R bus:bus /home/bus/bin
  434. sudo chown -R bus:bus /home/bus/database
  435. sudo chown -R bus:bus /home/bus/config
  436. echo ""
  437. if [[ "$tmpdir" != '' ]] ; then
  438. echo "... should remove $tmpdir"
  439. #rm -rf $tmdpri
  440. fi
  441. echo "done"