From b774ae72c155a3159dab5cf3437f51b61aab74ae Mon Sep 17 00:00:00 2001 From: Kewitt Date: Sat, 12 Jul 2025 18:41:44 +0000 Subject: [PATCH] Update config/autostart.sh --- config/autostart.sh | 193 ++++++++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 88 deletions(-) diff --git a/config/autostart.sh b/config/autostart.sh index d3f21d4..dae3ee6 100644 --- a/config/autostart.sh +++ b/config/autostart.sh @@ -1,6 +1,8 @@ #!/bin/bash -#This is for WHIT 2025.06.04 +#This is for UHI 1.0 Rebuild +#This build uses samba kodi fbi ffmpeg lftp apache2 php7.3 +#to set wifi ssh and use sudo raspi-config #--------------------------------------------------------------------------------------------------------------- #Config setting #supported image formats are jpeg, jpg, png, bmp. @@ -15,124 +17,81 @@ Server="//192.168.88.210/whit/tv1" USERNAME=local.admin PASSWORD=whitwhit #how long each picture will be turned into a video for. -time=10 +time=20 #Use if URL to Image is being used. -#Set content 1 = Video and/or images 2 = Just images 3 = URL and image 4 = Debug -content=2 +#Set content 1 = Video and/or images 4 = Debug +content=1 # #Update network -export wifiupdate=false -export essid=whit -export wifipassword=whitwhit -export updatehost=whit1 +#export wifiupdate=false +#export essid=whit +#export wifipassword=whitwhit +#export updatehost=whit1 #If you want to control the IP address please use dhcp reservation. #or manually set it up # # #If you are setting url you need to add to crontab -e to update the image every 15 mins, and enable urlchrome setting -#Change localhost to the +#Change localhost to the #sudo crontab -e #0/15 * * * * "chromium-browser --headless --window-size=1920x1080 --virtual-time-budget=25000 --screenshot=/home/$USER/WHIT/working/calander.png http://localhost" #urlchrome="chromium-browser --headless --window-size=1920x1080 --virtual-time-budget=25000 --screenshot=/home/$USER/WHIT/working/calander.png http://localhost" #when do you want the reboot to happen, 24 hour clock 0 = midnight -export reboottime=01:50 -export overscan=1 -export rotation=0 - - - - - +#export reboottime=01:50 +#export overscan=1 +#export rotation=0 #####PROGRAM DO NOT EDIT######## -echo echo Starting UHI echo $(date):Starting log file. > /home/$USER/WHIT/config/boot.log -echo -# Function to find the default gateway -find_gateway() { - ip route | awk '/default/ {print $3}' -} +echo $(date): >> /home/$USER/WHIT/config/boot.log -# Set retry count and interval -MAX_ATTEMPTS=6 -INTERVAL=10 -attempt=1 +program="cvlc --no-osd --width 1920 --height 1080 --quiet --nooverlay -L /home/$USER/WHIT/config/playlist.xspf" -while [ $attempt -le $MAX_ATTEMPTS ]; do - GATEWAY=$(find_gateway) +echo $program >> /home/$USER/WHIT/config/boot.log - if [ -n "$GATEWAY" ]; then - echo "Detected gateway: $GATEWAY" >> /home/$USER/WHIT/config/boot.log - break - fi - - echo "No gateway detected, retrying in $INTERVAL seconds..." >> /home/$USER/WHIT/config/boot.log - sleep $INTERVAL - ((attempt++)) -done - -echo $(date):Starting log file. > /home/$USER/WHIT/config/boot.log -echo $(date):>> /home/$USER/WHIT/config/boot.log - -if [ $content = "2" ]; then - program="fbi -noverbose -a -t $time -l /home/$USER/WHIT/config/images" -elif [ $content = "3" ]; then - program="fbi -noverbose --cachemem 1 -a -t $time -l /home/$USER/WHIT/config/images" -elif [ $content = "4" ]; then - program="echo DEBUG" -else - program=kodi -fi - -echo >> /home/$USER/WHIT/config/boot.log -echo $(date):Setting up wifi. >> /home/$USER/WHIT/config/boot.log - -if $wifiupdate; then -/home/$USER/WHIT/config/wifi.sh -exit -fi - -echo +echo "" hostname -s hostname -I -echo +echo "" echo >> /home/$USER/WHIT/config/boot.log echo "CHECK protocal: $protocal" >> /home/$USER/WHIT/config/boot.log if [ $protocal = 1 ]; then - echo $(date):Connecting to cifs share "$Server" to mounting point /mnt/whit >> /home/$USER/WHIT/config/boot.log - sudo mount -t cifs -o username=$USERNAME,password=$PASSWORD $Server /mnt/whit - else - echo $(date):Connecting to ftp share $Server to mounting point /mnt/whit >> /home/$USER/WHIT/config/boot.log - sudo curlftpfs -o allow_other $USERNAME:$PASSWORD@$Server /mnt/whit/ + echo $(date):Connecting to cifs share "$Server" to mounting point /mnt/whit >> /home/$USER/WHIT/config/boot.log + sudo mount -t cifs -o username=$USERNAME,password=$PASSWORD $Server /mnt/whit + else + echo $(date):Connecting to ftp share $Server to mounting point /mnt/whit >> /home/$USER/WHIT/config/boot.log + sudo curlftpfs -o allow_other $USERNAME:$PASSWORD@$Server /mnt/whit/ fi echo "====CHECK MOUNT===" >> /home/$USER/WHIT/config/boot.log if grep -qs '/mnt/whit ' /proc/mounts; then - echo $(date): /mnt/whit mounted correctly. >> /home/$USER/WHIT/config/boot.log + echo $(date): /mnt/whit mounted correctly. >> /home/$USER/WHIT/config/boot.log else echo $(date):did not mount /mnt/whit correctly. >> /home/$USER/WHIT/config/boot.log - echo $(date):Starting no mount point. >> /home/$USER/WHIT/config/boot.log - echo $(date):Starting $program >> /home/$USER/WHIT/config/boot.log - $program - exit + echo $(date):Starting no mount point. >> /home/$USER/WHIT/config/boot.log + echo $(date):Starting $program >> /home/$USER/WHIT/config/boot.log + clear + $program + exit fi echo "====CHECK DIFFERENCE===" >> /home/$USER/WHIT/config/boot.log if [ -z "$(diff -q -r /mnt/whit /home/$USER/WHIT/tv)" ]; then - echo >> /home/$USER/WHIT/config/boot.log - echo $(date):No changes found between local copy and network share. >> /home/$USER/WHIT/config/boot.log - echo $(date):Starting $program >>/home/$USER/WHIT/config/boot.log - echo $(date) No difference found. >> /home/$USER/WHIT/config/boot.log - echo Starting $program >> /home/$USER/WHIT/config/boot.log - sudo umount /mnt/whit - $program - exit + echo >> /home/$USER/WHIT/config/boot.log + echo $(date):No changes found between local copy and network share. >> /home/$USER/WHIT/config/boot.log + echo $(date):Starting $program >>/home/$USER/WHIT/config/boot.log + echo $(date) No difference found. >> /home/$USER/WHIT/config/boot.log + echo Starting $program >> /home/$USER/WHIT/config/boot.log + sudo umount /mnt/whit + clear + $program + exit fi echo >> /home/$USER/WHIT/config/boot.log @@ -142,20 +101,21 @@ echo $(date):Coping data from file share to local working folder.>> /home/$USER/ if [ -n "$(ls /mnt/whit/)" ]; then - echo Files found. >> /home/$USER/WHIT/config/boot.log - rsync -avu --delete "/mnt/whit/" "/home/$USER/WHIT/tv/" >> /home/$USER/WHIT/config/boot.log + echo Files found. >> /home/$USER/WHIT/config/boot.log + rsync -avu --delete "/mnt/whit/" "/home/$USER/WHIT/tv/" >> /home/$USER/WHIT/config/boot.log else - echo $(date):No files found in "'//mnt/whit/'" >> /home/$USER/WHIT/config/boot.log - echo $(date):Starting $program >> /home/$USER/WHIT/config/boot.log - sudo umount /mnt/whit - $program - exit + echo $(date):No files found in "'//mnt/whit/'" >> /home/$USER/WHIT/config/boot.log + echo $(date):Starting $program >> /home/$USER/WHIT/config/boot.log + sudo umount /mnt/whit + clear + $program + exit fi echo "====CHECK CLEANUP===" >> /home/$USER/WHIT/config/boot.log echo >> /home/$USER/WHIT/config/boot.log echo $(date):Cleaning up working path. >> /home/$USER/WHIT/config/boot.log -rm -v ~/working/* >> /home/$USER/WHIT/config/boot.log +rm -v /home/$USER/WHIT/working/* >> /home/$USER/WHIT/config/boot.log echo "====COPY CHECK===" >> /home/$USER/WHIT/config/boot.log echo >> /home/$USER/WHIT/config/boot.log @@ -172,6 +132,33 @@ find /home/$USER/WHIT/working/ -iname "*.bmp*" >> /home/$USER/WHIT/config/list cat /home/$USER/WHIT/config/list >> /home/$USER/WHIT/config/boot.log sort /home/$USER/WHIT/config/list > /home/$USER/WHIT/config/images + + + +echo "====resize imagers with padding===" >> /home/$USER/WHIT/config/boot.log + +# Directory containing images +input_dir="/home/$USER/WHIT/tv" +output_dir="/home/$USER/WHIT/working" + +# Ensure output directory exists +mkdir -p "$output_dir" + +# Loop through all image files in the input directory +for image in "$input_dir"/*.{jpg,jpeg,png,bmp}; do + [ -f "$image" ] || continue # Skip if not a file + + filename=$(basename "$image") + output_file="$output_dir/$filename" + + # Resize image with padding to fit 1920x1080 + convert "$image" -resize 1920x1080^ -gravity center -background black -extent 1920x1080 "$output_file" + + echo "Resized: $filename -> $output_file" +done + +echo "====ALL IMAGES resize imagers with padding===" >> /home/$USER/WHIT/config/boot.log + echo "CONTENT CHECK:$content" >> /home/$USER/WHIT/config/boot.log if [ $content = "1" ]; then echo Processing images ...... @@ -189,6 +176,36 @@ if [ $content = "1" ]; then done fi +# Set the folder containing your video files +MEDIA_DIR="/home/$USER/WHIT/working" +PLAYLIST_FILE="/home/$USER/WHIT/config/playlist.xspf" + +# Start the playlist XML structure +echo '' > "$PLAYLIST_FILE" +echo '' >> "$PLAYLIST_FILE" +echo ' ' >> "$PLAYLIST_FILE" + +# Loop through all files and filter for video formats dynamically +for FILE in "$MEDIA_DIR"/*; do + if [ -f "$FILE" ]; then + MIME_TYPE=$(file --mime-type -b "$FILE") + + # Check if the MIME type starts with "video/" + if [[ $MIME_TYPE == video/* ]]; then + echo " " >> "$PLAYLIST_FILE" + echo " file://$FILE" >> "$PLAYLIST_FILE" + echo " $(basename "$FILE")" >> "$PLAYLIST_FILE" + echo " " >> "$PLAYLIST_FILE" + fi + fi +done + +# Close the playlist XML structure +echo ' ' >> "$PLAYLIST_FILE" +echo '' >> "$PLAYLIST_FILE" + +echo "Playlist created: $PLAYLIST_FILE" + if [ $content = "3" ]; then echo "CONTENT CHECK:$content" >> /home/$USER/WHIT/config/boot.log $urlchrome