Update direwolf.sh

This commit is contained in:
RaspbianProyect by HP3ICC 2023-07-05 04:15:25 +00:00
parent 10c68df6cd
commit 4f09aa96d7
1 changed files with 28 additions and 33 deletions

View File

@ -3,6 +3,14 @@ cd /
if systemctl status direwolf.service |grep active >/dev/null 2>&1
then systemctl stop direwolf.service
fi
if systemctl status gpsd.socket |grep active >/dev/null 2>&1
then systemctl stop gpsd.socket
fi
if systemctl status gpsd |grep active >/dev/null 2>&1
then systemctl stop gpsd
fi
if [ -d "/opt/direwolf" ]
then
@ -16,27 +24,13 @@ then
#echo "found file"
fi
apps=("git" "gcc" "g++" "make" "cmake" "libasound2-dev" "libudev-dev" "libgps-dev" "gpsd" "libgps-dev" "ntp")
for app in "${apps[@]}"
do
# Verificar apps
if ! dpkg -s "$app" >/dev/null 2>&1; then
echo "app no instalada"
else
# app ya instalada
apt-get remove -y "$app"
apt-get purge -y "$app"
fi
done
#########################################################################################################################
# requeriments
#########################################################################################################################
apps=("git" "gcc" "g++" "make" "cmake" "libasound2-dev" "libudev-dev" "libgps-dev" "gpsd" "libgps-dev" "ntp")
apps=("git" "gcc" "g++" "make" "cmake" "libasound2-dev" "libudev-dev" "gpsd" "libgps-dev" "gpsd-clients" "gpsd-tools")
for app in "${apps[@]}"
do
@ -49,24 +43,25 @@ do
echo "$app ya instalada"
fi
done
#"ntp"
#apt-get install gpsd -y
#########################################################################################################################
# GPSD
#########################################################################################################################
cat > /etc/udev/rules.d/49-usb-gps.rules <<- "EOF"
KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", ATTRS{idVendor}=="1546", ATTRS{idProduct}=="01a7", SYMLINK="ttyACM0"
EOF
#cat > /etc/udev/rules.d/49-usb-gps.rules <<- "EOF"
#KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", ATTRS{idVendor}=="1546", ATTRS{idProduct}=="01a7", SYMLINK="ttyACM0"
#EOF
cat > /etc/default/gpsd <<- "EOF"
START_DAEMON="true"
USBAUTO="true"
DEVICES="/dev/ttyACM0"
GPSD_SOCKET="/var/run/gpsd.sock"
GPSD_OPTIONS="-n"
GPSD_SOCKET="/var/run/gpsd.sock"
EOF
#GPSD_SOCKET="/var/run/gpsd.sock"
sudo ln -sf /lib/systemd/system/gpsd.service /etc/systemd/system/multi-user.target.wants/
sudo systemctl stop gpsd
cat > /lib/systemd/system/gpsd.service <<- "EOFG"
[Unit]
@ -88,20 +83,20 @@ Also=gpsd.socket
EOFG
sudo systemctl daemon-reload
sudo systemctl start gpsd
archivo="/etc/ntp.conf"
palabra=("server 127.127.28.0 4" "fudge 127.127.28.0 time1 0.340 refid GPS" "server 127.127.28.1 prefer" "fudge 127.127.28.1 refid GPS1")
#sudo systemctl start gpsd
#archivo="/etc/ntp.conf"
#palabra=("server 127.127.28.0 4" "fudge 127.127.28.0 time1 0.340 refid GPS" "server 127.127.28.1 prefer" "fudge 127.127.28.1 refid GPS1")
for palabra in "${palabra[@]}"
do
#for palabra in "${palabra[@]}"
#do
if grep -i -E "$palabra" "$archivo" >/dev/null 2>&1; then
echo "line found"
else
echo "$palabra">> "$archivo"
fi
done
sudo /etc/init.d/ntp restart
#if grep -i -E "$palabra" "$archivo" >/dev/null 2>&1; then
# echo "line found"
# else
# echo "$palabra">> "$archivo"
#fi
#done
#sudo /etc/init.d/ntp restart
#########################################################################################################################
# direwolf