Mediawiki installation/write wmf-shared git-branches-tags2home skin-tags-and-branches.sh

From Biowikifarm Metawiki
Jump to: navigation, search

Run script write_wmf-shared_git-branches-tags2home_skin-tags-and-branches.sh not as copy and paste but from the command line. You can make the script executable by

# uog means: user who owns it (u), other users in the file's group (g), other users (o)
chmod u+x write_wmf-shared_git-branches-tags2home_skin-tags-and-branches.sh # add executable mode for the owned user
#!/bin/bash
# @name: write_wmf-shared_git-branches-tags2home_skin-tags-and-branches.sh
# @description: write git branch and tag of all skins in /usr/share/mw-wmf-clone/skins
#    to a file in the home directory: wmf-skins_tags_and_branches.txt
# @requires: a previous git pull and quick-update in /usr/share/mw-wmf-clone/skins

if ! [[ -d /usr/share/mw-wmf-clone/skins ]];then 
  echo "# Stop: /usr/share/mw-wmf-clone/skins dos not exist (stop here. exit: 1)"
  exit 1;
else
  echo '# Write git tags and branches to ~/wmf-skins_tags_and_branches.txt'
fi

##↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
# 1. INFORMATION ONLY:
# LIST (and write to file) git tags / git branches of all skins 
# Write into file in the user's home folder
printf "\n"  > ~/"wmf-skins_tags_and_branches.txt"; 
IFS=$'\n'; # change internal Field Separator to newline only; test: printf %q "$IFS"; default $' \t\n'
all_wmf_skins=`find /usr/share/mw-wmf-clone/skins -maxdepth 1 -not -name '.*' -type d -printf "%f\n" | sort`
n_maxchar_skin=`echo "$all_wmf_skins" | wc --max-line-length`
n_skin=` echo "$all_wmf_skins" | wc --lines`
i_skin=1
for this_skin in `find /usr/share/mw-wmf-clone/skins -maxdepth 1 -not -name '.*' -type d -printf "%f\n" | sort`; do 
  if [ -d "/usr/share/mw-wmf-clone/skins/$this_skin" ]; then
    printf "# skin (%3d of %3d) %-${n_maxchar_skin}s: append git branch/tag into your home directory: '~/wmf-skins_tags_and_branches.txt'\n" "$i_skin" "$n_skin" "'$this_skin'"
    printf "\n%s" "$this_skin" >> ~/"wmf-skins_tags_and_branches.txt"; 
    cd "/usr/share/mw-wmf-clone/skins/$this_skin";
    # List all skins with their branches, write into same file
    branches=""; branches=`git branch --remotes | sort --version-sort --ignore-case | sed 's@^ \+\(.\+\)[ ]*$@\1@;$!{ s@$@,@;}' | fmt - | sed 's@^\(.\+\)@    \1@;'`
    if [ "$branches" != "" ]; then 
      printf "\n  branches:\n%s" "$branches"  >> ~/"wmf-skins_tags_and_branches.txt"; 
    else 
      printf "\n" >> ~/"wmf-skins_tags_and_branches.txt"; 
    fi
    # List all skins with their tags, write into same file
    tags=""; tags=`git tag --list | sort --version-sort --ignore-case | sed 's@^ \+\(.\+\)[ ]*$@\1@;$!{ s@$@,@;}' | fmt - | sed 's@^\(.\+\)@    \1@;'` ; 
    if [ "$tags" != "" ]; then 
      printf "\n  tags:\n%s" "$tags" >> ~/"wmf-skins_tags_and_branches.txt"; 
    else 
      printf "\n"  >> ~/"wmf-skins_tags_and_branches.txt"; 
    fi
  fi
  i_skin=$((i_skin + 1))
done;
cd /usr/share/mw-wmf-clone/skins
IFS=$' \t\n';
# end list skins' tags and branches