diff --git a/bin/cosmic-web b/bin/cosmic-web index 36bd2be..5b20668 100755 --- a/bin/cosmic-web +++ b/bin/cosmic-web @@ -2,10 +2,24 @@ run_user=$(id -u) if [ "$run_user" -eq 0 ]; then + SCRIPT=$(readlink -f "$0") + SCRIPTPATH=$(dirname "$SCRIPT") + file_html="/var/www/html/index.html" + web_header_html="${SCRIPTPATH}/../files/web-header.tmpl" + ships_html="/var/www/html/ships/index.html" + error_html="/var/www/html/error.html" + html_dir="/var/www/html" + gopher_dir="/var/gopher" + + # Clear web folder + rm -rf "${html_dir:-/var/www/html}/*" + # Generate RSS + # shellcheck source=cosmic-rss + . "${SCRIPTPATH}/cosmic-rss" # Add standard header - cat "/home/tomasino/cosmic/files/web-header.tmpl" > "${file_html}" + cat "$web_header_html" > "${file_html}" # Custom header elements and body start { printf "
" # Intro text - cat "/var/gopher/intro.gophermap" + cat "${gopher_dir}/intro.gophermap" # Ship listings - printf "\\n🢒 Ships, Colonies, Outposts\\n\\n" + printf "\\n>> Ships, Colonies, Outposts\\n\\n" # Logs printf "Transmission Log:\\n" } >> "${file_html}" @@ -29,22 +43,22 @@ if [ "$run_user" -eq 0 ]; then logdir=$(dirname "$log") title=$(printf "%s" "$line" | awk -F'\t' '{print $1}' | sed 's|^.||') # print link in listings - printf "🢒 %s\\n" "$loghtml" "$title" >> "${file_html}" + printf ">> %s\\n" "$loghtml" "$title" >> "${file_html}" # create entry - entry_html="/var/www/html${loghtml}.html" - mkdir -p "/var/www/html${logdir}" - cat "/home/tomasino/cosmic/files/web-header.tmpl" > "${entry_html}" + entry_html="${html_dir}${loghtml}.html" + mkdir -p "${html_dir}${logdir}" + cat "$web_header_html" > "${entry_html}" { printf "%s \\n" "$title" printf " \\n" "$loghtml" printf "\\n\\n\\n" - printf "<<< BACK TO RELAY ONE\\n\\n\\n" - cat "/var/gopher${log}" + printf "<< BACK TO RELAY ONE\\n\\n\\n" + cat "${gopher_dir}${log}" # close up the entry footer printf "