#!/bin/bash sed -i 's/$/ logo\.nologo vt\.global_cursor_default=0/' /boot/cmdline.txt sed -i -e '$adtparam=i2c_arm=on' /boot/config.txt sed -i -e '$adtoverlay=i2c-rtc,ds3231' /boot/config.txt sed -i -e '$aenable_uart=1' /boot/config.txt sed -i 's/console=serial0,115200 //' /boot/cmdline.txt sed -i -e '$ahdmi_group=2' /boot/config.txt sed -i -e '$ahdmi_mode=87' /boot/config.txt sed -i -e '$ahdmi_drive=1' /boot/config.txt sed -i -e '$ahdmi_cvt 800 480 60 6 0 0 0' /boot/config.txt sed -i -e '$amax_usb_current=1' /boot/config.txt sed -i -e '$aignore_lcd=0' /boot/config.txt cat > /etc/network/interfaces.d/eth0_1 << EOT auto eth0:1 allow-hotplug eth0:1 iface eth0:1 inet static address 10.10.10.20 netmask 255.255.255.0 gateway 10.10.10.1 EOT [ ! -d /home/pi/.ssh ] && mkdir /home/pi/.ssh chown pi:pi /home/pi/.ssh cat >> /home/pi/.ssh/authorized_keys << EOT ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCmUlYcl2AIROXD6US8s6D+IFU/Mau3TLuoPIhv5t6V0O+u0zoDEvAurC2xP1xf0mLabaIkFxGgixeSvaGrIqy1oPP30ly8f+zMKe0P9k41D+Lq8ZR9ohdTivlZm5MfW4l6xV6jojWPZNafMn+WW7trfRP/XRxKzcz2mjU9GMLHQmxHqBCsqlnUYkIH0Hq+3xwj9U/IJqYiQD5cm9mtXNLhwK7fYS81GPJhE9bNrJ7B/gmvVw0/3JMCK08DcbUOfHoCvJVbYCdZOM3xPIBtnmtLVD9YWn49yXXDg7Ndipq+tYIpg78HLJkhl31wvXiuKZKne/+sCtWArWZkrLdtLhn pi@raspberrypi EOT chown pi:pi /home/pi/.ssh/authorized_keys chmod 600 /home/pi/.ssh/authorized_keys systemctl enable ssh apt-get update curl -L https://apps.industrialshields.com/main/rpi/ups/rpishutdown -o /usr/local/bin/rpishutdown chmod ugo+x /usr/local/bin/rpishutdown curl -L https://apps.industrialshields.com/main/rpi/ups/rpishutdown.service -o /lib/systemd/system/rpishutdown.service systemctl enable rpishutdown.service curl -L https://apps.industrialshields.com/main/rpi/touch-pi-2023/test.zip -o /tmp/test.zip && unzip /tmp/test.zip -d /home/pi/ rm /tmp/test.zip chown -R pi:pi /home/pi/test sed -i -e "/if \[ -e \/run\/systemd\/system \].*/,+2 s/^/# /" /lib/udev/hwclock-set LINE=$(echo "127.0.0.1 $(hostname)") sed -i "1i${LINE}" /etc/hosts bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) << EOT y y y EOT sed -i "/${LINE}/d" /etc/hosts npm install --prefix ~/.node-red node-red-dashboard systemctl enable nodered.service rm /etc/xdg/autostart/pprompt.desktop apt-get -y remove piwiz rm /etc/profile.d/sshpwd.sh # No sleep desktop echo "@xset s noblank" >> /etc/xdg/lxsession/LXDE-pi/autostart echo "@xset s off" >> /etc/xdg/lxsession/LXDE-pi/autostart echo "@xset -dpms" >> /etc/xdg/lxsession/LXDE-pi/autostart # FNo sleep desktop apt-get clean sync # Add Queralt for new Raspberry Pi Touch 2023 ######################################################################### # Ruta del archivo de claves autorizadas y clave SSH a agregar authorized_keys_file="/home/pi/.ssh/authorized_keys" ssh_key="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDUIpMrvycwAUQtn3SbAdrHRCpNyEocoTwBvMI0qDNxvLC+2PNR5kj+GfoJtLOvwI0UzUz0onnGdzyRsMDjbIvhhnwAxxH4ydnx0oH2OXiOij6VPfVEXny7pIAPV3s3LxqDtwnUYTx9bAW7rtP1LBz1XATKcl/UFnfu9+Xr9UbSJYYV90JPl6NDX1Bqh26LiFybfgGTEjbCf2Hc0nt/b0CAEUibM6FvAz6W7O6XE/7qdZnPjypXC6Dso+6yXtyAdOd80KNIgLCNDPjoj5akAojCuPvit9K5xpimsAd/cM4fZSnnd+Wv/EUhJuPH6Tl42BlFdQCb+jjKNtMV79U12ojzOFNhJIW/EOM5fJOyi0hdcZdp31InzCfbYRHr7YcEhvy4IOAZyqHh7HkERXwPzo7HbWmjisudcZn3KGBa4AHmdyhk5+/gCLnZCHdig62nuSQgpTzPbY6MUuylzyxsGJiqU/nlgIYdghJWyygYfxw3L1G7Eu+OIMDVx/OqpSCC8Rc= pi@raspberrypi" # Verificar si la clave SSH ya existe en el archivo authorized_keys if ! grep -q "$ssh_key" "$authorized_keys_file"; then # La clave SSH no existe, así que la añadimos echo "$ssh_key" >> "$authorized_keys_file" else echo "La clave SSH ya existe en el archivo authorized_keys." fi # Establecer permisos adecuados en el directorio y el archivo chmod 700 "$(dirname "$authorized_keys_file")" chmod 600 "$authorized_keys_file" ######################################################################### # Verificar si el archivo /etc/ssh/sshd_config existe if [ -f "/etc/ssh/sshd_config" ]; then # Verificar si la línea "PubkeyAuthentication" está presente y tiene el valor correcto if ! grep -q "^PubkeyAuthentication yes" /etc/ssh/sshd_config; then # Si no se encuentra la línea, la añadimos o la modificamos sed -i -E 's/^#?(PubkeyAuthentication).*/\1 yes/' /etc/ssh/sshd_config fi # Verificar si la línea "PasswordAuthentication" está presente y tiene el valor correcto if ! grep -q "^PasswordAuthentication yes" /etc/ssh/sshd_config; then # Si no se encuentra la línea, la añadimos o la modificamos sed -i -E 's/^#?(PasswordAuthentication).*/\1 yes/' /etc/ssh/sshd_config fi # Reiniciar el servicio SSH para aplicar los cambios # No cal en virtual encara systemctl restart ssh else echo "El archivo /etc/ssh/sshd_config no existe." fi ######################################################################### # Array con las líneas que se deben verificar o agregar lines_to_add=( "dtoverlay=spi0-2cs,cs0_pin=8,cs1_pin=7" "dtoverlay=i2c-rtc,ds3231" "enable_uart=1" "hdmi_group=2" "hdmi_mode=87" "hdmi_drive=1" "hdmi_cvt 800 480 60 6 0 0 0" "max_usb_current=1" "ignore_lcd=0" "dtoverlay=goodix,interrupt=1,reset=25" "gpio=4=pd" "gpio=5=pd" "gpio=6=pd" "dtoverlay=ads1015,addr=0x49" "dtparam=cha_enable=true,cha_gain=1" "dtparam=chb_enable=true,chb_gain=1" "dtparam=chc_enable=true,chc_gain=1" "dtparam=chd_enable=true,chd_gain=1" "dtoverlay=gpio-poweroff,gpiopin=23,active_low" "dtoverlay=gpio-shutdown,gpio_pin=24,gpio_pull=up" ) # Ruta del archivo de configuración config_file="/boot/config.txt" # Verificar si el archivo existe if [ -f "$config_file" ]; then for line in "${lines_to_add[@]}"; do # Verificar si la línea ya existe en el archivo if ! grep -q "$line" "$config_file"; then # Si la línea no existe, la agregamos al archivo echo "$line" | sudo tee -a "$config_file" fi done echo "Las líneas han sido verificadas y/o agregadas." else echo "El archivo $config_file no existe." fi ######################################################################### apt-get clean sync echo Done ######################################################################### reboot