#!/bin/bash # terminal-setup.sh # OpenDRS Online Maintenance Tracking System # Copyright (C) 2018 Rod Wright # SPDX-License-Identifier: GPL-2.0 echo "" echo "" echo "" echo "" echo "This script will configure a Raspberry Pi to be an OpenDRS terminal." echo "" echo "" echo "You should have already completed the following steps:" echo "" echo "1. Created a Raspbian Lite SD card from the latest release." echo "2. Installed the card in a Raspberry Pi, booted it, and logged in as pi." echo "3. Ran sudo raspi-config and :" echo " a. Set a strong password for the pi user." echo " b. Set hostname and, if accessing a network through wifi, the SSID and" echo " passphrase under Network Options." echo " c. Set locale, timezone, keyboard layout, and wifi country under" echo " Localisation Options." echo " d. Enable SSH under Interfacing Options." echo " e. Set overscan as required to get rid of any black borders around the" echo " edge of the display." echo " f. Reboot when prompted and logged back in as pi." echo "4. Transferred the OpenDRS distribution package to /home/pi on the" echo " Raspberry Pi and extracted it." echo "5. Changed directory to RPiSetup in the the extracted distribution directory." echo "6. Ran sudo ./terminal-setup.sh (this file)." echo "" echo "If you have completed these steps, press enter to continue. If not," echo -n "press ctrl-c to quit." read continueok echo "" echo "" echo "Updating Raspbian..." sleep 10 apt update && apt dist-upgrade -y echo "...done." echo "Copying files..." chmod +x usr/local/bin/* cp usr/local/bin/* /usr/local/bin cp etc/apt/sources.list.d/* /etc/apt/sources.list.d cp lib/systemd/system/getty@tty1.service /lib/systemd/system rm /lib/systemd/system/ctrl-alt-del.target ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target echo "...done." echo "" echo "" echo "Installing required terminal packages..." sleep 10 wget http://www.webmin.com/jcameron-key.asc apt-key add jcameron-key.asc rm jcameron-key.asc apt update apt install -y --no-install-recommends xorg openbox chromium-browser apt install -y webmin cups libcups2-dev cmake addgroup lpadmin usermod -a -G lpadmin pi systemctl enable getty@tty1.service service cups-browsed stop systemctl disable cups-browsed.service cp etc/cups/cupsd.conf /etc/cups/ service cups restart cd brlaser-master cmake . && make && make install cd .. myhn=`hostname` echo "Drivers have been installed for the Brother HL-L2300D printer that may come" echo "with the terminal." echo "After the terminal is set up and working, you can use another network" echo "computer to point a web browser to $myhn:631 to add this or another printer" echo "of your choosing." echo -n "Press enter to continue." read continueok echo "" echo "" echo "Creating customer user..." cloneuser pi customer mkdir -p /home/customer/.config/openbox cp home/customer/.profile /home/customer cp home/customer/.config/openbox/rc.xml /home/customer/.config/openbox chown -R customer:customer /home/customer/.config /home/customer/.profile echo "...done." echo "" echo "" echo "This terminal will need to communicate with an OpenDRS server. If" echo "you intend to host the server directly on this terminal, accept the" echo "default URL shown. Otherwise, enter the server URL." echo -n "[http://localhost] :" read server_url if [[ $server_url == "" ]] then server_url="http://localhost" fi echo "DRS_SERVER=\"$server_url\"" > /etc/drs.conf echo "" echo "" echo "Terminal configuration is now complete. " echo "" echo "" echo "If this Raspberry Pi will also be used as the OpenDRS server, you will need" echo "to run the server-setup.sh script in this same directory." echo "Would you like to do that now? enter Y if so, or press enter to leave this" echo -n "as a terminal only and reboot :" read serverchoice if [[ $serverchoice == "Y" || $serverchoice == "y" ]] then ./server-setup.sh fi echo "It is highly recommended that after rebooting, you press ctrl-alt-F2," echo "log in as pi, then create new users for yourself and any other" echo "administrators using the cloneuser command (cloneuser pi newlogin)." echo "" echo "" echo "Setup complete." echo -n "Press enter to reboot now." read rebootok reboot