From 85181b7d1e07fe2f30fa45226311ae14da6649e1 Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Thu, 21 Sep 2023 07:57:10 +0300 Subject: [PATCH] - improved setup script --- setup/setup_agent_gsm.sh | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/setup/setup_agent_gsm.sh b/setup/setup_agent_gsm.sh index a6aef55..ab71d90 100755 --- a/setup/setup_agent_gsm.sh +++ b/setup/setup_agent_gsm.sh @@ -10,8 +10,8 @@ INSTALL_DIR=agent_gsm GIT_SOURCE=https://git.sevana.biz/public/agent_gsm # Install prerequisites -sudo apt install --assume-yes git mc python3 sox vim libffi-dev screen python3-pip python3-numpy dnsmasq hostapd -sudo pip3 install pyyaml sox pyrabbit soundfile dbus_python pexpect pydub requests rabbitpy pydub reachability bottle +sudo apt install --assume-yes git mc python3 sox vim libffi-dev screen python3-pip python3-numpy dnsmasq hostapd screen +sudo pip3 install pyyaml sox pyrabbit soundfile dbus_python pexpect requests rabbitpy bottle if [ -f "$INSTALL_DIR" ]; then rm -rf "$INSTALL_DIR" @@ -45,7 +45,7 @@ cp config/agent.in.yaml config/agent.yaml mkdir -p ~/.config/mc cp config/mc/ini ~/.config/mc -# Replace the values +# Replace the values - finish preparing the agent configuration file if [[ $BACKEND_URL != "" ]]; then sed -i "s|BACKEND|$BACKEND|" config/agent.yaml fi @@ -56,11 +56,45 @@ fi sed -i "s|TASK_NAME|$TASK_NAME|" config/agent.yaml -# Update systemD unit file -cp config/systemd/agent_gsm.in.service config/systemd/agent_gsm.service ABSOLUTE_INSTALL_DIR=`realpath .` -sed -i "s|ABSOLUTE_INSTALL_DIR|$ABSOLUTE_INSTALL_DIR|" config/systemd/agent_gsm.service +# Update systemD unit file +# cp config/systemd/agent_gsm.in.service config/systemd/agent_gsm.service +# sed -i "s|ABSOLUTE_INSTALL_DIR|$ABSOLUTE_INSTALL_DIR|" config/systemd/agent_gsm.service + +install_ap() { + # $1 is AP name + sudo cp $ABSOLUTE_INSTALL_DIR/config/ap/etc/dhcpcd.conf /etc + sudo cp $ABSOLUTE_INSTALL_DIR/config/ap/etc/dnsmasq.conf /etc + sudo mkdir -p /etc/hostapd + sudo cp $ABSOLUTE_INSTALL_DIR/config/ap/etc/hostapd.conf /etc/hostapd + sudo sed -i "s|AGENT_GSM|$1|" /etc/hostapt/hostapd.conf + sudo cp $ABSOLUTE_INSTALL_DIR/config/ap/etc/default/hostapt /etd/default + sudo systemctl enable dnsmasq + sudo systemctl enable hostapd + sudo systemctl start dnsmasq + sudo systemctl start hostapd +} + +function enable_autologin() { + sudo systemctl --quiet set-default multi-user.target + sudo cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf << EOF +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin $USER --noclear %I \$TERM +EOF + +} + +# ToDo: +# - allow autologin in console mode for 'pi' user +enable_autologin + +# - add $ABSOLUTE_INSTALL_DIR/run_agent_screen.sh to ~/.bashrc +echo "$ABSOLUTE_INSTALL_DIR/run_agent_screen.sh" >> ~/.bashrc + +# - install wifi AP with name $PHONE_NAME +install_ap $PHONE_NAME echo "Now the remaining prerequisites will be installed and system will reboot." echo "You can connect the phone via Bluetooth after the reboot."