MOBILE-4286 github: Branch name changes
parent
d2e34e3d87
commit
7f7f547d4d
|
@ -27,29 +27,41 @@ function print_success {
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_error {
|
function print_error {
|
||||||
|
[[ -n "$TERM" ]] && tput setaf 1
|
||||||
echo " ERROR: $1"
|
echo " ERROR: $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_ok {
|
function print_ok {
|
||||||
|
[[ -n "$TERM" ]] && tput setaf 2
|
||||||
echo " OK: $1"
|
echo " OK: $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_message {
|
function print_message {
|
||||||
|
[[ -n "$TERM" ]] && tput setaf 3
|
||||||
echo "-------- $1"
|
echo "-------- $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_title {
|
function print_title {
|
||||||
stepnumber=$(($stepnumber + 1))
|
stepnumber=$(($stepnumber + 1))
|
||||||
echo
|
echo
|
||||||
|
[[ -n "$TERM" ]] && tput setaf 5
|
||||||
echo "$stepnumber $1"
|
echo "$stepnumber $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
|
[[ -n "$TERM" ]] && tput setaf 5
|
||||||
echo '=================='
|
echo '=================='
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
}
|
}
|
||||||
|
|
||||||
function telegram_notify {
|
function telegram_notify {
|
||||||
if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then
|
if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then
|
||||||
MESSAGE="Travis error: $1%0ABranch: $TRAVIS_BRANCH%0ARepo: $TRAVIS_REPO_SLUG"
|
set_branch_and_repo
|
||||||
|
|
||||||
|
MESSAGE="$1%0ABranch: *$REFNAME* on $REPO%0ACommit: $COMMIT%0AJob: $JOB ($RUN_NUMBER) [Complete log here]($JOB_URL)"
|
||||||
URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage"
|
URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage"
|
||||||
|
|
||||||
curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE"
|
curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE"
|
||||||
|
@ -64,6 +76,70 @@ function notify_on_error_exit {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function set_branch_and_repo {
|
||||||
|
if [ ! -z $REPO ]; then
|
||||||
|
# Already filled.
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $TRAVIS_OS_NAME ]; then
|
||||||
|
#Run on github
|
||||||
|
if [ "$RUNNER_OS" == 'macOS' ]; then
|
||||||
|
export OS_NAME='osx'
|
||||||
|
elif [ "$RUNNER_OS" == 'Linux' ]; then
|
||||||
|
export OS_NAME='linux'
|
||||||
|
elif [ "$RUNNER_OS" == 'Windows' ]; then
|
||||||
|
export OS_NAME='windows'
|
||||||
|
fi
|
||||||
|
export REFNAME=$GITHUB_REF_NAME
|
||||||
|
export REFTYPE=$GITHUB_REF_TYPE
|
||||||
|
export REPO=$GITHUB_REPOSITORY
|
||||||
|
export COMMIT=$GITHUB_SHA
|
||||||
|
export JOB=$GITHUB_JOB
|
||||||
|
export JOB_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
|
||||||
|
export RUN_NUMBER=$GITHUB_RUN_NUMBER
|
||||||
|
export CI_TYPE='github'
|
||||||
|
else
|
||||||
|
# Run on Travis
|
||||||
|
export OS_NAME=$TRAVIS_OS_NAME
|
||||||
|
if [ -z "$TRAVIS_TAG" ]; then
|
||||||
|
export REFTYPE='branch'
|
||||||
|
export REFNAME=$TRAVIS_BRANCH
|
||||||
|
else
|
||||||
|
export REFTYPE='tag'
|
||||||
|
export REFNAME=$TRAVIS_TAG
|
||||||
|
fi
|
||||||
|
export REPO=$TRAVIS_REPO_SLUG
|
||||||
|
export COMMIT=$TRAVIS_COMMIT
|
||||||
|
export JOB=$TRAVIS_JOB_NAME
|
||||||
|
export JOB_URL=$TRAVIS_JOB_WEB_URL
|
||||||
|
export RUN_NUMBER=$TRAVIS_BUILD_NUMBER
|
||||||
|
export CI_TYPE='travis'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $REFNAME ]; then
|
||||||
|
print_error "Empty branch/tag, cancelling..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $REPO ]; then
|
||||||
|
print_error "Empty repo, cancelling..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_title "Build info:"
|
||||||
|
echo "OS_NAME: $OS_NAME"
|
||||||
|
echo "REFNAME: $REFNAME"
|
||||||
|
echo "REFTYPE: $REFTYPE"
|
||||||
|
echo "REPO: $REPO"
|
||||||
|
echo "COMMIT: $COMMIT"
|
||||||
|
echo "JOB: $JOB"
|
||||||
|
echo "JOB_URL: $JOB_URL"
|
||||||
|
echo "RUN_NUMBER: $RUN_NUMBER"
|
||||||
|
echo "CI_TYPE: $CI_TYPE"
|
||||||
|
}
|
||||||
|
|
||||||
function get_behat_plugin_changes_diff {
|
function get_behat_plugin_changes_diff {
|
||||||
# Grab hashes from app repository
|
# Grab hashes from app repository
|
||||||
currenthash=`git rev-parse HEAD`
|
currenthash=`git rev-parse HEAD`
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source "./.github/scripts/functions.sh"
|
source "./.github/scripts/functions.sh"
|
||||||
BRANCH=${GITHUB_REF##*/}
|
|
||||||
|
|
||||||
if [ -z $GIT_TOKEN ] || [ -z $BRANCH ] || [ $GITHUB_REPOSITORY != 'moodlehq/moodleapp' ]; then
|
if [ -z $GIT_TOKEN ] || [ -z $GITHUB_REF_NAME ] || [ $GITHUB_REPOSITORY != 'moodlehq/moodleapp' ]; then
|
||||||
print_error "Env vars not correctly defined"
|
print_error "Env vars not correctly defined"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git remote add mirror https://$GIT_TOKEN@github.com/moodlemobile/moodleapp.git
|
git remote add mirror https://$GIT_TOKEN@github.com/moodlemobile/moodleapp.git
|
||||||
git push -f mirror HEAD:$BRANCH
|
git push -f mirror HEAD:$GITHUB_REF_NAME
|
||||||
notify_on_error_exit "MIRROR: Unsuccessful mirror, stopping..."
|
notify_on_error_exit "MIRROR: Unsuccessful mirror, stopping..."
|
||||||
git push -f mirror --tags
|
git push -f mirror --tags
|
||||||
notify_on_error_exit "MIRROR: Unsuccessful mirror tags, stopping..."
|
notify_on_error_exit "MIRROR: Unsuccessful mirror tags, stopping..."
|
||||||
|
|
|
@ -7,7 +7,6 @@ if [ -z $GIT_TOKEN ] || [ $GITHUB_REPOSITORY != 'moodlemobile/moodleapp' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_title "Run prepare scripts"
|
print_title "Run prepare scripts"
|
||||||
# TODO Change branch name.
|
|
||||||
git clone --depth 1 --single-branch --branch ionic5 https://$GIT_TOKEN@github.com/moodlemobile/apps-scripts.git ../scripts
|
git clone --depth 1 --single-branch --branch ionic5 https://$GIT_TOKEN@github.com/moodlemobile/apps-scripts.git ../scripts
|
||||||
cp ../scripts/*.sh scripts/
|
cp ../scripts/*.sh scripts/
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ fi
|
||||||
# Clone plugin repository.
|
# Clone plugin repository.
|
||||||
print_title "Cloning Behat plugin repository..."
|
print_title "Cloning Behat plugin repository..."
|
||||||
|
|
||||||
git clone https://$GIT_TOKEN@github.com/$BEHAT_PLUGIN_GITHUB_REPOSITORY.git tmp/local_moodleappbehat -b integration
|
git clone https://$GIT_TOKEN@github.com/$BEHAT_PLUGIN_GITHUB_REPOSITORY.git tmp/local_moodleappbehat -b $GITHUB_REF_NAME
|
||||||
pluginversion=$(cat tmp/local_moodleappbehat/version.php | grep "\$plugin->version" | grep -o -E "[0-9]+")
|
pluginversion=$(cat tmp/local_moodleappbehat/version.php | grep "\$plugin->version" | grep -o -E "[0-9]+")
|
||||||
|
|
||||||
# Auto-generate plugin.
|
# Auto-generate plugin.
|
||||||
|
|
|
@ -16,9 +16,7 @@ on:
|
||||||
required: true
|
required: true
|
||||||
default: 'https://github.com/moodle/moodle'
|
default: 'https://github.com/moodle/moodle'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [ main, v*.x ]
|
||||||
- integration
|
|
||||||
- unscheduled
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
behat:
|
behat:
|
||||||
|
|
|
@ -2,7 +2,7 @@ name: Mirror
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master, main, unscheduled, integration, beta ]
|
branches: [ main, v*.x ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
mirror:
|
mirror:
|
||||||
|
|
|
@ -2,7 +2,7 @@ name: Prepare
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master, main, unscheduled, integration, beta, freemium-master, freemium-main ]
|
branches: [ main, freemium-main, v*.x, freemium-v*.x ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prepare:
|
prepare:
|
||||||
|
|
|
@ -7,7 +7,6 @@ if [ -z $GIT_TOKEN ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_title "Run scripts"
|
print_title "Run scripts"
|
||||||
# TODO Change branch name.
|
|
||||||
git clone --depth 1 --single-branch --branch ionic5 https://$GIT_TOKEN@github.com/moodlemobile/apps-scripts.git ../scripts
|
git clone --depth 1 --single-branch --branch ionic5 https://$GIT_TOKEN@github.com/moodlemobile/apps-scripts.git ../scripts
|
||||||
cp ../scripts/*.sh scripts/
|
cp ../scripts/*.sh scripts/
|
||||||
|
|
||||||
|
|
|
@ -27,29 +27,41 @@ function print_success {
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_error {
|
function print_error {
|
||||||
tput setaf 1; echo " ERROR: $1"; tput sgr0
|
[[ -n "$TERM" ]] && tput setaf 1
|
||||||
|
echo " ERROR: $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_ok {
|
function print_ok {
|
||||||
tput setaf 2; echo " OK: $1"; tput sgr0
|
[[ -n "$TERM" ]] && tput setaf 2
|
||||||
|
echo " OK: $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_message {
|
function print_message {
|
||||||
tput setaf 3; echo "-------- $1"; tput sgr0
|
[[ -n "$TERM" ]] && tput setaf 3
|
||||||
|
echo "-------- $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_title {
|
function print_title {
|
||||||
stepnumber=$(($stepnumber + 1))
|
stepnumber=$(($stepnumber + 1))
|
||||||
echo
|
echo
|
||||||
tput setaf 5; echo "$stepnumber $1"; tput sgr0
|
[[ -n "$TERM" ]] && tput setaf 5
|
||||||
tput setaf 5; echo '=================='; tput sgr0
|
echo "$stepnumber $1"
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
|
[[ -n "$TERM" ]] && tput setaf 5
|
||||||
|
echo '=================='
|
||||||
|
[[ -n "$TERM" ]] && tput sgr0
|
||||||
}
|
}
|
||||||
|
|
||||||
function telegram_notify {
|
function telegram_notify {
|
||||||
if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then
|
if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then
|
||||||
MESSAGE="Travis error: $1%0ABranch: $TRAVIS_BRANCH%0ARepo: $TRAVIS_REPO_SLUG"
|
set_branch_and_repo
|
||||||
|
|
||||||
|
MESSAGE="$1%0ABranch: *$REFNAME* on $REPO%0ACommit: $COMMIT%0AJob: $JOB ($RUN_NUMBER) [Complete log here]($JOB_URL)"
|
||||||
URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage"
|
URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage"
|
||||||
|
|
||||||
curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE"
|
curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE"
|
||||||
|
@ -63,3 +75,67 @@ function notify_on_error_exit {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function set_branch_and_repo {
|
||||||
|
if [ ! -z $REPO ]; then
|
||||||
|
# Already filled.
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $TRAVIS_OS_NAME ]; then
|
||||||
|
#Run on github
|
||||||
|
if [ "$RUNNER_OS" == 'macOS' ]; then
|
||||||
|
export OS_NAME='osx'
|
||||||
|
elif [ "$RUNNER_OS" == 'Linux' ]; then
|
||||||
|
export OS_NAME='linux'
|
||||||
|
elif [ "$RUNNER_OS" == 'Windows' ]; then
|
||||||
|
export OS_NAME='windows'
|
||||||
|
fi
|
||||||
|
export REFNAME=$GITHUB_REF_NAME
|
||||||
|
export REFTYPE=$GITHUB_REF_TYPE
|
||||||
|
export REPO=$GITHUB_REPOSITORY
|
||||||
|
export COMMIT=$GITHUB_SHA
|
||||||
|
export JOB=$GITHUB_JOB
|
||||||
|
export JOB_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
|
||||||
|
export RUN_NUMBER=$GITHUB_RUN_NUMBER
|
||||||
|
export CI_TYPE='github'
|
||||||
|
else
|
||||||
|
# Run on Travis
|
||||||
|
export OS_NAME=$TRAVIS_OS_NAME
|
||||||
|
if [ -z "$TRAVIS_TAG" ]; then
|
||||||
|
export REFTYPE='branch'
|
||||||
|
export REFNAME=$TRAVIS_BRANCH
|
||||||
|
else
|
||||||
|
export REFTYPE='tag'
|
||||||
|
export REFNAME=$TRAVIS_TAG
|
||||||
|
fi
|
||||||
|
export REPO=$TRAVIS_REPO_SLUG
|
||||||
|
export COMMIT=$TRAVIS_COMMIT
|
||||||
|
export JOB=$TRAVIS_JOB_NAME
|
||||||
|
export JOB_URL=$TRAVIS_JOB_WEB_URL
|
||||||
|
export RUN_NUMBER=$TRAVIS_BUILD_NUMBER
|
||||||
|
export CI_TYPE='travis'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $REFNAME ]; then
|
||||||
|
print_error "Empty branch/tag, cancelling..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $REPO ]; then
|
||||||
|
print_error "Empty repo, cancelling..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_title "Build info:"
|
||||||
|
echo "OS_NAME: $OS_NAME"
|
||||||
|
echo "REFNAME: $REFNAME"
|
||||||
|
echo "REFTYPE: $REFTYPE"
|
||||||
|
echo "REPO: $REPO"
|
||||||
|
echo "COMMIT: $COMMIT"
|
||||||
|
echo "JOB: $JOB"
|
||||||
|
echo "JOB_URL: $JOB_URL"
|
||||||
|
echo "RUN_NUMBER: $RUN_NUMBER"
|
||||||
|
echo "CI_TYPE: $CI_TYPE"
|
||||||
|
}
|
||||||
|
|
|
@ -10,58 +10,66 @@ DEFAULT_LASTVERSION='4.1' # Update it every version.
|
||||||
|
|
||||||
# Checks if AWS is available and configured.
|
# Checks if AWS is available and configured.
|
||||||
function check_aws {
|
function check_aws {
|
||||||
AWS_SERVICE=1
|
if [ ! -z $AWS_SERVICE ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
export AWS_SERVICE=1
|
||||||
|
|
||||||
aws --version &> /dev/null
|
aws --version &> /dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
AWS_SERVICE=0
|
export AWS_SERVICE=0
|
||||||
echo 'AWS not installed. Check https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html for more info.'
|
echo 'AWS not installed. Check https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html for more info.'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# In order to login to AWS, use credentials file or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY vars.
|
# In order to login to AWS, use credentials file or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY vars.
|
||||||
if [ ! -f ~/.aws/credentials ] && ([ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ]); then
|
if [ ! -f ~/.aws/credentials ] && ([ -z "$AWS_ACCESS_KEY_ID" ] || [ -z "$AWS_SECRET_ACCESS_KEY" ]); then
|
||||||
AWS_SERVICE=0
|
export AWS_SERVICE=0
|
||||||
lastversion=$DEFAULT_LASTVERSION
|
|
||||||
echo 'AWS Cannot authenticate. Use aws configure or set the proper env vars.'
|
echo 'AWS Cannot authenticate. Use aws configure or set the proper env vars.'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get last version of Moodle to fetch latest languages.
|
function list_aws_files {
|
||||||
function get_last_version {
|
local folder="$1"
|
||||||
if [ ! -z "${lastversion}" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
check_aws
|
check_aws
|
||||||
if [ $AWS_SERVICE -eq 0 ]; then
|
|
||||||
lastversion=$DEFAULT_LASTVERSION
|
if [ $AWS_SERVICE -eq 1 ]; then
|
||||||
echo "Using default version $lastversion"
|
export AWS_FOLDERS=`aws s3 ls s3://$BUCKET/$1`
|
||||||
|
else
|
||||||
|
export AWS_FOLDERS=[]
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get last version of Moodle to fetch latest languages.
|
||||||
|
function get_lang_version {
|
||||||
|
if [ ! -z "${LANGVERSION}" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
list=`aws s3 ls s3://$BUCKET/`
|
APP_VERSION=`jq -r '.versionname' ../moodle.config.json| cut -d. -f1-2`
|
||||||
if [ $? -ne 0 ]; then
|
if [ ! -z $APP_VERSION ]; then
|
||||||
AWS_SERVICE=0
|
export LANGVERSION=$APP_VERSION
|
||||||
lastversion=$DEFAULT_LASTVERSION
|
echo "Using app version $LANGVERSION"
|
||||||
echo "AWS Cannot authenticate. Using default version $lastversion"
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lastversion=''
|
list_aws_files ''
|
||||||
for folder in $list; do
|
LANGVERSION=''
|
||||||
|
for folder in $AWS_FOLDERS; do
|
||||||
if [ $folder != 'PRE' ]; then
|
if [ $folder != 'PRE' ]; then
|
||||||
lastversion=${folder/\//}
|
LANGVERSION=${folder/\//}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -z "${lastversion}" ]; then
|
if [ ! -z "${LANGVERSION}" ]; then
|
||||||
echo "Last version $lastversion detected"
|
echo "Using last version $LANGVERSION detected"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lastversion=$DEFAULT_LASTVERSION
|
LANGVERSION=$DEFAULT_LASTVERSION
|
||||||
|
echo "Using default version $LANGVERSION"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create langfolder
|
# Create langfolder
|
||||||
|
@ -71,21 +79,23 @@ function create_langfolder {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get all language list from AWS.
|
# Get language list from the installed ones (will not discover new translations).
|
||||||
function get_all_languages_aws {
|
function get_language_folders {
|
||||||
langsfiles=`aws s3 ls s3://$BUCKET/$lastversion/`
|
list_aws_files "$LANGVERSION/"
|
||||||
|
|
||||||
langs=""
|
langs=""
|
||||||
for file in $langsfiles; do
|
for file in $AWS_FOLDERS; do
|
||||||
if [[ "$file" == *.zip ]]; then
|
if [[ "$file" == *.zip ]]; then
|
||||||
file=${file/\.zip/}
|
file=${file/\.zip/}
|
||||||
langs+="$file "
|
langs+="$file "
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
|
||||||
|
|
||||||
# Get language list from the installed ones (will not discover new translations).
|
if [ -z "${LANGVERSION}" ]; then
|
||||||
function get_installed_languages {
|
# Get language list from the installed ones (will not discover new translations).
|
||||||
langs=`jq -r '.languages | keys[]' ../moodle.config.json`
|
echo "Fallback language list will only get current installation languages"
|
||||||
|
langs=`jq -r '.languages | keys[]' ../moodle.config.json`
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Entry function to get a language file.
|
# Entry function to get a language file.
|
||||||
|
@ -93,7 +103,7 @@ function get_language {
|
||||||
lang=$1
|
lang=$1
|
||||||
lang=${lang/-/_}
|
lang=${lang/-/_}
|
||||||
|
|
||||||
get_last_version
|
get_lang_version
|
||||||
|
|
||||||
create_langfolder
|
create_langfolder
|
||||||
|
|
||||||
|
@ -101,7 +111,7 @@ function get_language {
|
||||||
|
|
||||||
pushd $LANGPACKSFOLDER > /dev/null
|
pushd $LANGPACKSFOLDER > /dev/null
|
||||||
|
|
||||||
curl -s $MOODLEORG_URL/$lastversion/$lang.zip --output $lang.zip > /dev/null
|
curl -s $MOODLEORG_URL/$LANGVERSION/$lang.zip --output $lang.zip > /dev/null
|
||||||
size=$(du -k "$lang.zip" | cut -f 1)
|
size=$(du -k "$lang.zip" | cut -f 1)
|
||||||
if [ ! -n $lang.zip ] || [ $size -le 1 ]; then
|
if [ ! -n $lang.zip ] || [ $size -le 1 ]; then
|
||||||
echo "Wrong language name or corrupt file for $lang"
|
echo "Wrong language name or corrupt file for $lang"
|
||||||
|
@ -115,7 +125,7 @@ function get_language {
|
||||||
unzip -o -u $lang.zip > /dev/null
|
unzip -o -u $lang.zip > /dev/null
|
||||||
|
|
||||||
# This is the AWS version to get the language but right now it's slower.
|
# This is the AWS version to get the language but right now it's slower.
|
||||||
# aws s3 cp s3://$BUCKET/$lastversion/$lang.zip . > /dev/null
|
# aws s3 cp s3://$BUCKET/$LANGVERSION/$lang.zip . > /dev/null
|
||||||
|
|
||||||
rm $lang.zip
|
rm $lang.zip
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
@ -128,7 +138,7 @@ function get_languages {
|
||||||
suffix=''
|
suffix=''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_last_version
|
get_lang_version
|
||||||
|
|
||||||
if [ -d $LANGPACKSFOLDER ]; then
|
if [ -d $LANGPACKSFOLDER ]; then
|
||||||
lastupdate=`date -r $LANGPACKSFOLDER +%s`
|
lastupdate=`date -r $LANGPACKSFOLDER +%s`
|
||||||
|
@ -142,14 +152,7 @@ function get_languages {
|
||||||
create_langfolder
|
create_langfolder
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
get_language_folders
|
||||||
if [ $AWS_SERVICE -eq 1 ]; then
|
|
||||||
get_all_languages_aws
|
|
||||||
suffix=''
|
|
||||||
else
|
|
||||||
echo "Fallback language list will only get current installation languages"
|
|
||||||
get_installed_languages
|
|
||||||
fi
|
|
||||||
|
|
||||||
for lang in $langs; do
|
for lang in $langs; do
|
||||||
get_language "$lang"
|
get_language "$lang"
|
||||||
|
|
|
@ -14,7 +14,7 @@ print_title 'Generating language from code...'
|
||||||
npx gulp lang
|
npx gulp lang
|
||||||
|
|
||||||
print_title 'Getting local mobile langs'
|
print_title 'Getting local mobile langs'
|
||||||
git clone --branch master --depth 1 https://github.com/moodlehq/moodle-local_moodlemobileapp.git ../../moodle-local_moodlemobileapp
|
git clone --depth 1 https://github.com/moodlehq/moodle-local_moodlemobileapp.git ../../moodle-local_moodlemobileapp
|
||||||
|
|
||||||
if [ -z $forceLang ]; then
|
if [ -z $forceLang ]; then
|
||||||
get_languages
|
get_languages
|
||||||
|
|
|
@ -52,7 +52,7 @@ export class CoreSettingsLicensesPage implements OnInit {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.appLicenseVersion = CoreConstants.CONFIG.versionname.indexOf('-') > 0
|
this.appLicenseVersion = CoreConstants.CONFIG.versionname.indexOf('-') > 0
|
||||||
? 'integration'
|
? 'main'
|
||||||
: 'v' + CoreConstants.CONFIG.versionname;
|
: 'v' + CoreConstants.CONFIG.versionname;
|
||||||
|
|
||||||
this.licensesUrl = 'https://raw.githubusercontent.com/moodlehq/moodleapp/' + this.appLicenseVersion + '/licenses.json';
|
this.licensesUrl = 'https://raw.githubusercontent.com/moodlehq/moodleapp/' + this.appLicenseVersion + '/licenses.json';
|
||||||
|
|
Loading…
Reference in New Issue