git_update_index_html.sh (1232B)
1 #!/usr/bin/env sh 2 # SPDX-License-Identifier: AGPL-3.0-or-later 3 # SPDX-FileCopyrightText: 2021-2024 JayVii <jayvii[AT]posteo[DOT]de> 4 5 # $1 - HTML Root 6 # $2 - prv/pub 7 8 # Error out if not all options are given 9 if [ -z "$2" ]; then 10 echo "Usage: 11 git_update_index_html.sh \\ 12 \"/var/www/git.example.git\" \\ 13 \"pub\" 14 " 15 exit 1; 16 fi 17 18 # find respositories, sort them by update time 19 REPOS=`find "${1}"/"${2}" \ 20 -maxdepth 1 \ 21 -type d \ 22 -name "*.git" \ 23 -printf "%T+\t%p\n" | \ 24 sort -r | \ 25 awk '{print $2}'` 26 27 # build index HTML 28 stagit-index $REPOS > "${1}/${2}/index.html" 29 30 # ensure that repos link to index rather than log 31 sed -e 's/log\.html/index.html/g' -i "${1}/${2}/index.html" 32 33 # linking assets 34 ln -sf "${1}/assets/style.min.css" "${1}/${2}/style.css" 35 ln -sf "${1}/assets/favicon.png" "${1}/${2}/favicon.png" 36 ln -sf "${1}/assets/favicon.png" "${1}/${2}/logo.png" 37 38 # link htaccess 39 ln -sf "${1}/htaccess" "${1}/.htaccess" 40 41 # Modules ---------------------------------------------------------------------- 42 43 # Activity module 44 if [ -f "${1}/bin/activity.sh" ]; then 45 ACTIVITY_HTML=`${1}/bin/activity.sh $REPOS` 46 sed "/<div id=\"content\">/a${ACTIVITY_HTML}" \ 47 -i "${1}/${2}/index.html" 48 fi