Skip to content

Commit

Permalink
Merge pull request #320 from Sunbird-cQube/dev
Browse files Browse the repository at this point in the history
merge dev to staging
  • Loading branch information
htvenkatesh authored Jul 3, 2023
2 parents 42836a7 + eb76f14 commit 382b43c
Show file tree
Hide file tree
Showing 10 changed files with 320 additions and 5 deletions.
1 change: 1 addition & 0 deletions ansible/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vars_files:
- ../config_files/config.yml
- ../config_files/program_selector.yml
- ../config_files/national_program_selector.yml
- ../config_files/aws_s3_config.yml
- ../config_files/azure_container_config.yml
- ../config_files/local_storage_config.yml
Expand Down
1 change: 1 addition & 0 deletions ansible/localhost_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
vars_files:
- ../config_files/config.yml
- ../config_files/program_selector.yml
- ../config_files/national_program_selector.yml
- ../config_files/aws_s3_config.yml
- ../config_files/azure_container_config.yml
- ../config_files/local_storage_config.yml
Expand Down
1 change: 1 addition & 0 deletions ansible/public_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
vars_files:
- ../config_files/config.yml
- ../config_files/program_selector.yml
- ../config_files/national_program_selector.yml
- ../config_files/aws_s3_config.yml
- ../config_files/azure_container_config.yml
- ../config_files/local_storage_config.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
- name: Generating program selection csv file
- name: Generating state program selection csv file
template:
src: program_selector.csv.j2
dest: "../microservices/query-builder/program_selector.csv"
mode: "0644"
when: access_type == "VSK"
tags: [ install, update ]

- name: Generating national program selection csv file
template:
src: national_program_selector.csv.j2
dest: "../microservices/query-builder/program_selector.csv"
mode: "0644"
when: access_type == "NVSK"
tags: [ install, update ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
program_id,status
nishtha,{% if nishtha == true %}true{% else %}false{% endif %}{{''}}
pgi,{% if pgi == true %}true{% else %}false{% endif %}{{''}}
pmPoshan,{% if pmPoshan == true %}true{% else %}false{% endif %}{{''}}
diksha,{% if diksha == true %}true{% else %}false{% endif %}{{''}}
microImprovements,{% if microImprovements == true %}true{% else %}false{% endif %}{{''}}
nas,{% if nas == true %}true{% else %}false{% endif %}{{''}}
udisePlus,{% if udisePlus == true %}true{% else %}false{% endif %}{{''}}
nipunBharat,{% if nipunBharat == true %}true{% else %}false{% endif %}{{''}}
ncertQuiz,{% if ncertQuiz == true %}true{% else %}false{% endif %}{{''}}
ncf,{% if ncf == true %}true{% else %}false{% endif %}{{''}}
28 changes: 26 additions & 2 deletions ansible/roles/nginx/templates/default.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,32 @@ server {
listen 80;
listen [::]:80;

root /usr/share/nginx/html;
index index.html index.htm;
gzip on;
gzip_types application/javascript text/css;
gzip_min_length 1000;
gzip_static on;
root /usr/share/nginx/html;
server_tokens off;
index index.html index.htm index.nginx-debian.html;

add_header X-Frame-Options "SAMEORIGIN";
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
add_header X-Content-Type-Options nosniff;
add_header Content-Security-Policy "default-src https://apis.mapmyindia.com 'self'; font-src https://fonts.gstatic.com https://cdnjs.cloudflare.com https://fonts.googleapis.com 'self' data:; script-src https://code.jquery.com https://cdnjs.cloudflare.com https://apis.mapmyindia.com 'unsafe-inline' 'self'; style-src https://fonts.googleapis.com https://cdnjs.cloudflare.com https://maxcdn.bootstrapcdn.com 'unsafe-inline' 'self'; img-src https://*.basemaps.cartocdn.com 'self'";
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css";
add_header Referrer-Policy "strict-origin";
add_header Permissions-Policy "geolocation=(),midi=(),sync-xhr=(),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()";

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
#proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Accept-Encoding "";

server_name {{ api_endpoint }};

Expand Down
1 change: 1 addition & 0 deletions ansible/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- ../config_files/upgradation_local_storage_config.yml
- ../config_files/upgradation_oracle_storage_config.yml
- ../config_files/program_selector.yml
- ../config_files/national_program_selector.yml
- ../config_files/upgradation_oracle_storage_config.yml
- ../.version

Expand Down
10 changes: 10 additions & 0 deletions config_files/national_program_selector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
nishtha: true
pgi: true
pmPoshan: true
diksha: true
microImprovements: true
nas: true
udisePlus: true
nipunBharat: true
ncertQuiz: true
ncf: true
10 changes: 8 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ if [[ $storage_type == "oracle" ]]; then
fi

#Running script to generate program selector config file
chmod u+x shell_scripts/program_selector.sh
. "shell_scripts/program_selector.sh"
access_type=$(awk ''/^access_type:' /{ if ($2 !~ /#.*/) {print $2}}' config_files/config.yml)
if [[ $access_type == "VSK" ]]; then
chmod u+x shell_scripts/program_selector.sh
. "shell_scripts/program_selector.sh"
else
chmod u+x shell_scripts/national_program_selector.sh
. "shell_scripts/national_program_selector.sh"
fi

#Running script to clone all the required repositories
chmod u+x shell_scripts/repository_clone.sh
Expand Down
251 changes: 251 additions & 0 deletions shell_scripts/national_program_selector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
#!/bin/bash

check_microImprovements(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable microImprovements program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read micro_Improvements
if ! [[ $micro_Improvements == "true" || $micro_Improvements == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "microImprovements: $micro_Improvements\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_ncf(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable ncf program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read n_cf
if ! [[ $n_cf == "true" || $n_cf == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "ncf: $n_cf\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_ncertQuiz(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable ncertQuiz program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read ncert_Quiz
if ! [[ $ncert_Quiz == "true" || $ncert_Quiz == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "ncertQuiz: $ncert_Quiz\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_nipunBharat(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable nipunBharat program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read nipun_Bharat
if ! [[ $nipun_Bharat == "true" || $nipun_Bharat == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "nipunBharat: $nipun_Bharat\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_udise_plus(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable udise+ program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read udise_plus
if ! [[ $udise_plus == "true" || $udise_plus == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "udise+: $udise_plus\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_pgi(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable pgi program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read pg_i
if ! [[ $pg_i == "true" || $pg_i == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "pgi: $pg_i\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_pmPoshan(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable pmPoshan program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read pm_Poshan
if ! [[ $pm_Poshan == "true" || $pm_Poshan == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "pmPoshan: $pm_Poshan\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_nas(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable nas program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read n_as
if ! [[ $n_as == "true" || $n_as == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "nas: $n_as\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_diksha(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable diksha program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read dik_sha
if ! [[ $dik_sha == "true" || $dik_sha == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "diksha: $dik_sha\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_nishtha(){
while true
do
echo -e "\e[0;36m${bold}Hint: Enter true or false to enable nishtha program ${normal}"
echo -e "\e[0;38m${bold}please enter true or false.${normal}"
read nish_tha
if ! [[ $nish_tha == "true" || $nish_tha == "false" ]]; then
echo -e "\e[0;31m${bold}Error - Please enter either true or false ${normal}"; fail=1
else
printf "nishtha: $nish_tha\n" >> config_files/national_program_selector.yml
break;

fi
done
}

check_config_file(){
if [[ -e "config_files/national_program_selector.yml" ]]; then
while true; do
echo -e "\e[0;33m${bold}please preview the national_program_selector.yml file and confirm if everything is correct.${normal}"
echo -e "\e[0;38m${bold} `cat config_files/national_program_selector.yml` ${normal}"
echo -e "\e[0;33m${bold}Currently cQube national_program_selector.yml is entered. Follow Installation process with above config values.${normal}"
echo -e "\e[0;33m${bold}If you want to edit config value please enter yes.${normal}"
while true; do

read -p "Do you still want to edit the national_program_selector.yml file (yes/no)? " yn
case $yn in
yes) break;;
no) break 2;;
* ) echo "Please answer yes or no.";;
esac
done

if [[ $yn == yes ]]; then

if [[ -e "config_files/national_program_selector.yml" ]]; then
rm config_files/national_program_selector.yml
touch config_files/national_program_selector.yml
check_microImprovements
check_ncf
check_ncertQuiz
check_nipunBharat
check_udise_plus
check_pgi
check_pmPoshan
check_nas
check_diksha
check_nishtha
fi
fi
done
fi
if [[ $yn == no ]]; then
echo -e "\e[0;32m${bold}national_program_selector file has been generated and validated successfully${normal}"

fi

}


check_program_file(){
if [[ -e "config_files/national_program_selector.yml" ]]; then
while true; do
echo -e "\e[0;33m${bold}please preview the national_program_selector.yml file and confirm if everything is correct.${normal}"
echo -e "\e[0;38m${bold} `cat config_files/national_program_selector.yml` ${normal}"
echo -e "\e[0;33m${bold}Currently cQube program_selector.yml is entered. Follow Installation process with above config values.${normal}"
echo -e "\e[0;33m${bold}If you want to edit config value please enter yes.${normal}"
while true; do

read -p "Do you still want to edit the national_program_selector.yml file (yes/no)? " yn
case $yn in
yes) break;;
no) break 2;;
* ) echo "Please answer yes or no.";;
esac
done
if [[ -e "config_files/national_program_selector.yml" ]]; then
if [[ $yn == yes ]]; then
rm config_files/program_selector.yml
touch config_files/program_selector.yml
check_microImprovements
check_ncf
check_ncertQuiz
check_nipunBharat
check_udise_plus
check_pgi
check_pmPoshan
check_nas
check_diksha
check_nishtha

fi
fi
done
fi
if [[ $yn == no ]]; then
echo -e "\e[0;32m${bold}national_program_selector file has been generated and validated successfully${normal}"

fi

}

check_config_file


0 comments on commit 382b43c

Please sign in to comment.