From 646edee1d1802a421b89fa3758a377ce5f0c3bb8 Mon Sep 17 00:00:00 2001 From: Aaron Johnson Date: Sat, 29 Jan 2022 06:54:39 -0600 Subject: [PATCH] Inital Working Scripts --- MyGMRS_Configure.sh | 14 +++++++++----- MyGMRS_Setup.sh | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/MyGMRS_Configure.sh b/MyGMRS_Configure.sh index 3015e2a..40d2c83 100755 --- a/MyGMRS_Configure.sh +++ b/MyGMRS_Configure.sh @@ -32,11 +32,12 @@ DATE=`date +%Y%m%d%H%M%S` for FILE in rpt.conf extensions.conf iax.conf savenode.conf simpleusb.conf usbradio.conf -if [ -e ${FILE}.org-$0 ] +do +if [ -f "${FILE}.org-`basename $0`" ] then - if [ -e ${FILE} ] + if [ -f "${FILE}" ] then - if [ -e ${FILE}_bak-$DATE ] + if [ -f "${FILE}_bak-$DATE" ] then echo "Error: Backup file ${FILE}_bak-$DATE already exists, not handled by this script" exit -1 @@ -45,11 +46,13 @@ then mv ${FILE} ${FILE}_bak-$DATE fi # restore orginal config to template version - /bin/cp -f ${FILE}.org-$0 ${FILE} + /bin/cp -f ${FILE}.org-`basename $0` ${FILE} else # Org file before running this script not found, create one - /bin/cp -f ${FILE} ${FILE}.org-$0 + /bin/cp -f ${FILE} ${FILE}.org-`basename $0` fi +done + echo "Setting node number in rpt.conf..." sed -i "s/1999/$NODE/g" rpt.conf @@ -98,6 +101,7 @@ echo "Updating hosts file..." echo "127.0.1.1 node-"$NODE"" >> /etc/hosts echo "Configuration complete! Restarting..." +rm ~repeater/.MyGMRSNeedConfig reboot diff --git a/MyGMRS_Setup.sh b/MyGMRS_Setup.sh index a857d9b..f043745 100755 --- a/MyGMRS_Setup.sh +++ b/MyGMRS_Setup.sh @@ -113,6 +113,22 @@ ${x86} && dpkg-reconfigure asl-dahdi-linux-dkms echo "Disabling als-menu" chmod -x /usr/local/sbin/asl-menu +echo "Setting sudoers for MyGMRS_Configure.sh" +echo "repeater ALL=NOPASSWD:/usr/local/sbin/MyGMRS_Configure.sh" > /etc/sudoers.d/mygmrs +passwd repeater +passwd -e repeater +touch ~repeater/.MyGMRSNeedConfig +chown repeater:repeater ~repeater/.MyGMRSNeedConfig + +echo "if [ -f ~/.MyGMRSNeedConfig ] +then + sudo /usr/local/sbin/MyGMRS_Configure.sh + rm ~/.MyGMRSNeedConfig +fi" >> ~repeater/.profile + +> /var/mail/repeater +history -c + echo "Configuration complete! Restarting..." reboot