Kareha Rotating Banner Help August 21, 2018 09:45PM |
Registered: 6 years ago Posts: 5 |
Re: Kareha Rotating Banner Help August 22, 2018 06:28PM |
Admin Registered: 14 years ago Posts: 4,680 |
Re: Kareha Rotating Banner Help August 22, 2018 09:03PM |
Registered: 6 years ago Posts: 5 |
Re: Kareha Rotating Banner Help August 23, 2018 01:47AM |
Registered: 6 years ago Posts: 5 |
#!/bin/sh files=(/opt/piratebox/share/content/img/*) new_image=$(printf "%s\n" "${files[RANDOM % ${#files[@]}]}" | cut -c 21-) #this section required to add escape characters to the variable $new_image NL=' ' case $new_image in (*"$NL"*) echo >&2 "Sorry, can't handle variables with newline characters" exit 1 esac escaped_new_image=$(printf '%s\n' "$new_image" | sed 's:[][\/.^$*]:\\&:g') # base template for sed command: Ignore this if you want #sed "0,/$escaped_var/s/$escaped_var/replacement/" < file sed -i '17s/.*/use constant TITLEIMG => '\'"$escaped_new_image"\'';/' /opt/piratebox/share/board/config.pl
sudo ./banner_rotate.shYou should not receive any errors. Check config.pl to see if the script has worked and indeed did define a path to a different image on the TITLEIMG line.