freedombone-utils-setup 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Setup functions
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. if [ ! $PROJECT_NAME ]; then
  31. PROJECT_NAME='freedombone'
  32. fi
  33. DEFAULT_DOMAIN_NAME=
  34. DEFAULT_DOMAIN_CODE=
  35. MY_USERNAME=
  36. if [ ! $SYSTEM_TYPE ]; then
  37. SYSTEM_TYPE="full"
  38. fi
  39. # An optional configuration file which overrides some of these variables
  40. if [ ! $CONFIGURATION_FILE ]; then
  41. CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
  42. fi
  43. # Directory where source code is downloaded and compiled
  44. INSTALL_DIR=$HOME/build
  45. # device name for an attached usb drive
  46. USB_DRIVE=/dev/sda1
  47. # Location where the USB drive is mounted to
  48. USB_MOUNT=/mnt/usb
  49. # Number of days to keep backups for
  50. BACKUP_MAX_DAYS=30
  51. # file containing a list of remote locations to backup to
  52. # Format: [username@friendsdomain//home/username] [ssh_password]
  53. # With the only space character being between the server and the password
  54. FRIENDS_SERVERS_LIST=/home/$MY_USERNAME/backup.list
  55. export DEBIAN_FRONTEND=noninteractive
  56. # used to limit CPU usage
  57. CPULIMIT='/usr/bin/cpulimit -l 20 -e'
  58. # command to create a git repository
  59. CREATE_GIT_PROJECT_COMMAND='create-project'
  60. # File which keeps track of what has already been installed
  61. COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
  62. # log file where details of remote backups are stored
  63. REMOTE_BACKUPS_LOG=/var/log/remotebackups.log
  64. # message if something fails to install
  65. CHECK_MESSAGE="Check your internet connection, /etc/network/interfaces and /etc/resolv.conf, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list."
  66. # Default diffie-hellman key length in bits
  67. DH_KEYLENGTH=2048
  68. function detect_usb_drive {
  69. # sets to the highest available drive letter
  70. # which is likely to be the last drive connected
  71. read_config_param USB_DRIVE
  72. partition_number='1'
  73. if [[ "$1" == "nopath" ]]; then
  74. partition_number=''
  75. fi
  76. if [ -b /dev/sdb${partition_number} ]; then
  77. USB_DRIVE=/dev/sdb${partition_number}
  78. fi
  79. if [ -b /dev/sdc${partition_number} ]; then
  80. USB_DRIVE=/dev/sdc${partition_number}
  81. fi
  82. if [ -b /dev/sdd${partition_number} ]; then
  83. USB_DRIVE=/dev/sdd${partition_number}
  84. fi
  85. if [ -b /dev/sde${partition_number} ]; then
  86. USB_DRIVE=/dev/sde${partition_number}
  87. fi
  88. if [ -b /dev/sdf${partition_number} ]; then
  89. USB_DRIVE=/dev/sdf${partition_number}
  90. fi
  91. if [ -b /dev/sdg${partition_number} ]; then
  92. USB_DRIVE=/dev/sdg${partition_number}
  93. fi
  94. if [ -b /dev/sdh${partition_number} ]; then
  95. USB_DRIVE=/dev/sdh${partition_number}
  96. fi
  97. write_config_param USB_DRIVE "$USB_DRIVE"
  98. }
  99. function remove_bluetooth {
  100. rmmod -f bnep
  101. rmmod -f bluetooth
  102. if [ -f /etc/default/bluetooth ]; then
  103. if grep "BLUETOOTH_ENABLED=" /etc/default/bluetooth; then
  104. sed -i 's|BLUETOOTH_ENABLED=.*|BLUETOOTH_ENABLED=0|g' /etc/default/bluetooth
  105. else
  106. echo "BLUETOOTH_ENABLED=0" >> /etc/default/bluetooth
  107. fi
  108. fi
  109. if ! grep 'blacklist bnep' /etc/modprobe.d/bluetooth.conf; then
  110. echo 'blacklist bnep' >> /etc/modprobe.d/bluetooth.conf
  111. fi
  112. if ! grep 'blacklist btusb' /etc/modprobe.d/bluetooth.conf; then
  113. echo 'blacklist btusb' >> /etc/modprobe.d/bluetooth.conf
  114. fi
  115. if ! grep 'blacklist bluetooth' /etc/modprobe.d/bluetooth.conf; then
  116. echo 'blacklist bluetooth' >> /etc/modprobe.d/bluetooth.conf
  117. fi
  118. update-initramfs -u -k `uname -r` -v
  119. update-rc.d bluetooth remove
  120. }
  121. function running_as_root {
  122. if [[ $EUID != 0 ]] ; then
  123. echo "0"
  124. else
  125. echo "1"
  126. fi
  127. }
  128. function reset_usb_devices {
  129. for xhci in /sys/bus/pci/drivers/?hci-pci ; do
  130. if ! cd $xhci ; then
  131. return
  132. fi
  133. echo "Resetting devices from $xhci..."
  134. for i in ????:??:??.? ; do
  135. echo -n "$i" > unbind
  136. echo -n "$i" > bind
  137. done
  138. done
  139. udevadm control --reload-rules
  140. }
  141. function install_backports_kernel {
  142. # install backports kernel if possible
  143. architecture_type=$(uname -a)
  144. if [[ "$architecture_type" == *"amd64"* ]]; then
  145. apt-get -yq install linux-image-amd64 -t jessie-backports
  146. fi
  147. }
  148. function turn_off_rsys_logging {
  149. sed -i 's|mail,news.none.*|mail,news.none /dev/null|g' /etc/rsyslog.conf
  150. sed -i 's|auth,authpriv.\*.*|auth,authpriv.\* /dev/null|g' /etc/rsyslog.conf
  151. sed -i 's|mail.info.*|mail.info /dev/null|g' /etc/rsyslog.conf
  152. sed -i 's|mail.warn.*|mail.warn /dev/null|g' /etc/rsyslog.conf
  153. sed -i 's|mail.err.*|mail.err /dev/null|g' /etc/rsyslog.conf
  154. sed -i 's|daemon.\*.*|daemon.\* /dev/null|g' /etc/rsyslog.conf
  155. sed -i 's|mail.\*.*|mail.\* /dev/null|g' /etc/rsyslog.conf
  156. sed -i 's|user.\*.*|user.\* /dev/null|g' /etc/rsyslog.conf
  157. sed -i 's|news.none;mail.none.*|news.none;mail.none /dev/null|g' /etc/rsyslog.conf
  158. sed -i 's|\*.\*;auth,authpriv.none.*|\*.\*;auth,authpriv.none /dev/null|g' /etc/rsyslog.conf
  159. sed -i 's|#cron.\*|cron.\*|g' /etc/rsyslog.conf
  160. sed -i 's|cron.\*.*|cron.\* /dev/null|g' /etc/rsyslog.conf
  161. shred -zu /var/log/wtmp*
  162. shred -zu /var/log/debug*
  163. shred -zu /var/log/cron.*
  164. shred -zu /var/log/auth.*
  165. shred -zu /var/log/mail.*
  166. shred -zu /var/log/daemon.*
  167. shred -zu /var/log/user.*
  168. shred -zu /var/log/messages*
  169. }
  170. function initial_setup {
  171. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  172. return
  173. fi
  174. apt-get -yq remove --purge apache*
  175. apt-get -yq dist-upgrade
  176. apt-get -yq install ca-certificates
  177. apt-get -yq install apt-utils
  178. apt-get -yq install cryptsetup libgfshare-bin obnam sshpass wget avahi-daemon
  179. apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
  180. apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
  181. apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
  182. apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
  183. apt-get -yq install libnss-gw-name nano man ntp locales locales-all debconf
  184. apt-get -yq install wireless-tools wpasupplicant usbutils cryptsetup zsh
  185. apt-get -yq install pinentry-curses eatmydata iotop bc grub2 hostapd haveged
  186. apt-get -yq install cpulimit
  187. if [ ! -d $INSTALL_DIR ]; then
  188. mkdir -p $INSTALL_DIR
  189. fi
  190. mark_completed $FUNCNAME
  191. }
  192. function admin_user_sudo {
  193. if ! grep -q "$MY_USERNAME ALL=(ALL) ALL" $rootdir/etc/sudoers; then
  194. echo "$MY_USERNAME ALL=(ALL) ALL" >> $rootdir/etc/sudoers
  195. fi
  196. }
  197. function search_for_attached_usb_drive {
  198. # If a USB drive is attached then search for email,
  199. # gpg, ssh keys and emacs configuration
  200. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  201. return
  202. fi
  203. detect_usb_drive
  204. if [ -b $USB_DRIVE ]; then
  205. if [ ! -d $USB_MOUNT ]; then
  206. echo $'Mounting USB drive'
  207. mkdir $USB_MOUNT
  208. mount $USB_DRIVE $USB_MOUNT
  209. fi
  210. if [ -d $USB_MOUNT/.gnupg ]; then
  211. echo $'Importing GPG keyring'
  212. cp -r $USB_MOUNT/.gnupg /home/$MY_USERNAME
  213. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
  214. GPG_KEYS_IMPORTED="yes"
  215. if [ ! -f /home/$MY_USERNAME/.gnupg/secring.gpg ]; then
  216. echo $'GPG files did not copy'
  217. exit 73529
  218. fi
  219. fi
  220. if [ -f $USB_MOUNT/private_key.gpg ]; then
  221. echo $'GPG private key found on USB drive'
  222. MY_GPG_PRIVATE_KEY=$USB_MOUNT/private_key.gpg
  223. fi
  224. if [ -f $USB_MOUNT/public_key.gpg ]; then
  225. echo $'GPG public key found on USB drive'
  226. MY_GPG_PUBLIC_KEY=$USB_MOUNT/public_key.gpg
  227. fi
  228. if [ -f $USB_MOUNT/letsencrypt ]; then
  229. echo $'Copying letsencrypt keys"'
  230. cp -r $USB_MOUNT/letsencrypt /etc
  231. fi
  232. if [ -d $USB_MOUNT/.ssh ]; then
  233. echo $'Importing ssh keys'
  234. cp -r $USB_MOUNT/.ssh /home/$MY_USERNAME
  235. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
  236. # for security delete the ssh keys from the usb drive
  237. if [ ! -f /home/$MY_USERNAME/.ssh/id_rsa ]; then
  238. echo $'ssh files did not copy'
  239. exit 8
  240. fi
  241. fi
  242. if [ -f $USB_MOUNT/.emacs ]; then
  243. echo $'Importing .emacs file'
  244. cp -f $USB_MOUNT/.emacs /home/$MY_USERNAME/.emacs
  245. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs
  246. fi
  247. if [ -d $USB_MOUNT/.emacs.d ]; then
  248. echo $'Importing .emacs.d directory'
  249. cp -r $USB_MOUNT/.emacs.d /home/$MY_USERNAME
  250. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.emacs.d
  251. fi
  252. if [ -d $USB_MOUNT/ssl ]; then
  253. echo $'Importing SSL certificates'
  254. cp -r $USB_MOUNT/ssl/* /etc/ssl
  255. chmod 640 /etc/ssl/certs/*
  256. chmod 400 /etc/ssl/private/*
  257. # change ownership of some certificates
  258. if [ -d /etc/prosody ]; then
  259. chown prosody:prosody /etc/ssl/private/xmpp.*
  260. chown prosody:prosody /etc/ssl/certs/xmpp.*
  261. fi
  262. if [ -d /etc/dovecot ]; then
  263. chown root:dovecot /etc/ssl/certs/dovecot.*
  264. chown root:dovecot /etc/ssl/private/dovecot.*
  265. fi
  266. if [ -f /etc/ssl/private/exim.key ]; then
  267. cp /etc/ssl/private/exim.key /etc/exim4
  268. cp /etc/ssl/certs/exim.crt /etc/exim4
  269. cp /etc/ssl/certs/exim.dhparam /etc/exim4
  270. chown root:Debian-exim /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
  271. chmod 640 /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
  272. fi
  273. fi
  274. if [ -d $USB_MOUNT/personal ]; then
  275. echo $'Importing personal directory'
  276. cp -r $USB_MOUNT/personal /home/$MY_USERNAME
  277. chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/personal
  278. fi
  279. else
  280. if [ -d $USB_MOUNT ]; then
  281. umount $USB_MOUNT
  282. rm -rf $USB_MOUNT
  283. fi
  284. echo $'No USB drive attached'
  285. fi
  286. mark_completed $FUNCNAME
  287. }
  288. function mark_admin_user_account {
  289. set_completion_param "Admin user" "$MY_USERNAME"
  290. }
  291. function remove_instructions_from_motd {
  292. sed -i '/## /d' /etc/motd
  293. }
  294. function remove_default_user {
  295. # make sure you don't use the default user account
  296. if [[ $MY_USERNAME == "debian" ]]; then
  297. echo 'Do not use the default debian user account. Create a different user with: adduser [username]'
  298. exit 68
  299. fi
  300. # remove the default debian user to prevent it from becoming an attack vector
  301. if [ -d /home/debian ]; then
  302. userdel -r debian
  303. echo 'Default debian user account removed'
  304. fi
  305. }
  306. function create_completion_file {
  307. if [ ! -f $COMPLETION_FILE ]; then
  308. touch $COMPLETION_FILE
  309. fi
  310. }
  311. function upgrade_installation {
  312. # TODO
  313. echo ''
  314. }
  315. function disable_nfs_insecure_locks {
  316. apt-get -yq install nfs-kernel-server
  317. if grep 'insecure_locks' /etc/exports; then
  318. sed -i 's|,insecure_locks||g' /etc/exports
  319. sed -i 's|insecure_locks,||g' /etc/exports
  320. exportfs -a
  321. fi
  322. }
  323. function set_login_umask {
  324. sed -i 's|UMASK\t.*|UMASK\t\t077|g' /etc/login.defs
  325. }
  326. function setup_firewall {
  327. function_check create_completion_file
  328. create_completion_file
  329. function_check configure_firewall
  330. configure_firewall
  331. function_check configure_firewall_ping
  332. configure_firewall_ping
  333. function_check configure_firewall_for_dns
  334. configure_firewall_for_dns
  335. function_check configure_firewall_for_avahi
  336. configure_firewall_for_avahi
  337. function_check global_rate_limit
  338. global_rate_limit
  339. }
  340. function setup_utils {
  341. read_config_param "PROJECT_REPO"
  342. write_config_param "PROJECT_REPO" "$PROJECT_REPO"
  343. function_check remove_bluetooth
  344. remove_bluetooth
  345. function_check disable_nfs_insecure_locks
  346. disable_nfs_insecure_locks
  347. function_check set_login_umask
  348. set_login_umask
  349. function_check turn_off_rsys_logging
  350. turn_off_rsys_logging
  351. function_check install_backports_kernel
  352. install_backports_kernel
  353. function_check create_completion_file
  354. create_completion_file
  355. function_check read_configuration
  356. read_configuration
  357. function_check check_system_type
  358. check_system_type
  359. function_check upgrade_installation
  360. upgrade_installation
  361. function_check set_default_onion_domains
  362. set_default_onion_domains
  363. function_check locale_setup
  364. locale_setup
  365. function_check parse_args
  366. parse_args
  367. function_check check_domains
  368. check_domains
  369. function_check install_static_network
  370. install_static_network
  371. function_check remove_default_user
  372. remove_default_user
  373. function_check setup_firewall
  374. setup_firewall
  375. function_check create_repo_sources
  376. create_repo_sources
  377. function_check configure_dns
  378. configure_dns
  379. function_check initial_setup
  380. initial_setup
  381. function_check install_tor
  382. install_tor
  383. #function_check resolve_dns_via_tor
  384. #resolve_dns_via_tor
  385. function_check install_command_line_browser
  386. install_command_line_browser
  387. function_check enable_ssh_via_onion
  388. enable_ssh_via_onion
  389. function_check check_date
  390. check_date
  391. function_check install_dynamicdns
  392. install_dynamicdns
  393. function_check randomize_cron
  394. randomize_cron
  395. function_check create_freedns_updater
  396. create_freedns_updater
  397. function_check mark_admin_user_account
  398. mark_admin_user_account
  399. function_check enforce_good_passwords
  400. enforce_good_passwords
  401. function_check change_login_message
  402. change_login_message
  403. function_check enable_zram
  404. enable_zram
  405. function_check random_number_generator
  406. random_number_generator
  407. function_check set_your_domain_name
  408. set_your_domain_name
  409. function_check configure_internet_protocol
  410. configure_internet_protocol
  411. function_check create_git_project
  412. create_git_project
  413. function_check setup_wifi
  414. setup_wifi
  415. function_check configure_ssh
  416. configure_ssh
  417. function_check configure_ssh_onion
  418. configure_ssh_onion
  419. function_check allow_ssh_to_onion_address
  420. allow_ssh_to_onion_address
  421. function_check remove_instructions_from_motd
  422. remove_instructions_from_motd
  423. function_check check_hwrng
  424. check_hwrng
  425. function_check search_for_attached_usb_drive
  426. search_for_attached_usb_drive
  427. function_check regenerate_ssh_keys
  428. regenerate_ssh_keys
  429. function_check create_mirrors
  430. create_mirrors
  431. function_check create_upgrade_script
  432. create_upgrade_script
  433. function_check letsencrypt_renewals
  434. letsencrypt_renewals
  435. function_check install_watchdog_script
  436. install_watchdog_script
  437. function_check install_avahi
  438. install_avahi
  439. function_check create_avahi_onion_domains
  440. create_avahi_onion_domains
  441. #function_check install_atheros_wifi
  442. #install_atheros_wifi
  443. function_check route_outgoing_traffic_through_tor
  444. route_outgoing_traffic_through_tor
  445. function_check upgrade_golang
  446. upgrade_golang
  447. function_check install_tomb
  448. install_tomb
  449. function_check admin_user_sudo
  450. admin_user_sudo
  451. }
  452. function setup_email {
  453. function_check create_completion_file
  454. create_completion_file
  455. function_check install_email
  456. install_email
  457. function_check create_procmail
  458. create_procmail
  459. function_check handle_admin_emails
  460. handle_admin_emails
  461. function_check spam_filtering
  462. spam_filtering
  463. function_check configure_imap
  464. configure_imap
  465. #function_check configure_imap_client_certs
  466. #configure_imap_client_certs
  467. function_check configure_gpg
  468. configure_gpg
  469. function_check refresh_gpg_keys
  470. refresh_gpg_keys
  471. function_check configure_backup_key
  472. configure_backup_key
  473. function_check install_monkeysphere
  474. install_monkeysphere
  475. function_check encrypt_incoming_email
  476. encrypt_incoming_email
  477. function_check encrypt_outgoing_email
  478. encrypt_outgoing_email
  479. function_check email_client
  480. email_client
  481. function_check email_archiving
  482. email_archiving
  483. function_check email_from_address
  484. email_from_address
  485. function_check create_public_mailing_list
  486. create_public_mailing_list
  487. #function check create_private_mailing_list
  488. #create_private_mailing_list
  489. function_check encrypt_all_email
  490. encrypt_all_email
  491. function_check import_email
  492. import_email
  493. }
  494. function setup_web {
  495. function_check create_completion_file
  496. create_completion_file
  497. function_check install_web_server
  498. install_web_server
  499. function_check install_web_server_access_control
  500. install_web_server_access_control
  501. }
  502. function upgrade_apps {
  503. function_check create_completion_file
  504. create_completion_file
  505. APPS_COMPLETED=()
  506. FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
  507. # for all the app scripts
  508. for filename in $FILES
  509. do
  510. app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
  511. item_in_array "${app_name}" "${APPS_COMPLETED[@]}"
  512. if [[ $? != 0 ]]; then
  513. function_check app_is_installed
  514. if [[ "$(app_is_installed $a)" == "1" ]]; then
  515. app_load_variables ${app_name}
  516. APPS_COMPLETED+=("${app_name}")
  517. function_check upgrade_${app_name}
  518. upgrade_${app_name}
  519. fi
  520. fi
  521. done
  522. }
  523. function setup_apps {
  524. is_interactive=$1
  525. function_check create_completion_file
  526. create_completion_file
  527. function_check detect_installable_apps
  528. detect_installable_apps
  529. function_check choose_apps_for_variant
  530. choose_apps_for_variant "$SYSTEM_TYPE"
  531. echo $"System variant: $SYSTEM_TYPE"
  532. echo $'The following apps have been selected'
  533. echo ''
  534. function_check list_chosen_apps
  535. list_chosen_apps
  536. echo ''
  537. function_check upgrade_apps
  538. upgrade_apps
  539. if [[ $is_interactive == "menuconfig"* ]]; then
  540. ${PROJECT_NAME}-addremove add-all
  541. if [ ! "$?" = "0" ]; then
  542. exit 72524
  543. fi
  544. fi
  545. if [[ $is_interactive == "noninteractive" || $is_interactive == "headless" ]]; then
  546. function_check install_apps
  547. install_apps
  548. if [ ! $APP_INSTALLED_SUCCESS ]; then
  549. echo $'One or more apps failed to install'
  550. fi
  551. fi
  552. }
  553. function combine_all_scripts {
  554. combined_filename=$1
  555. # initial variables
  556. cp $PROJECT_INSTALL_DIR/${PROJECT_NAME}-vars $combined_filename
  557. # utilities
  558. UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
  559. for f in $UTILS_FILES
  560. do
  561. # this removes the first line, which is #!/bin/bash
  562. tail -n +2 "$f" >> $combined_filename
  563. done
  564. # base system
  565. BASE_SYSTEM_FILES=/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-*
  566. for f in $BASE_SYSTEM_FILES
  567. do
  568. tail -n +2 "$f" >> $combined_filename
  569. done
  570. # apps
  571. APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
  572. for f in $APP_FILES
  573. do
  574. tail -n +2 "$f" >> $combined_filename
  575. done
  576. }
  577. # NOTE: deliberately no exit 0