#ATTENTION
#DON'T run it in svn folder - it REMOVES files
#Copy project in another location eg "deploy-folder"
#go to "deploy-folder/deploy"
#uncomment the proper commands
#run the script

# cp theproperties file according to the deploy environment!!!
## uncommect one of the following -->
# cp beta-properties.json ../src/assets/env-properties.json;
# cp production-properties.json ../src/assets/env-properties.json;

## uncommect from here-->
# printf  '\nCheck that you have the correct properties file';
# echo -n "Press key:";
# read -n1 ans
# pico ../src/assets/env-properties.json;
# printf  '\nCheck the properties file version';
# echo -n "Press key:";
# read -n1 ans
# pico ../src/app/openaireLibrary/utils/properties/environment-specific.service.ts;
# echo 'For Production keep meta for bots';
# printf  '\n\nCheck index.html: For test and beta keep meta for noindex, for production remove noindex and keep meta for Search engines verification';
# printf  '\nUpdate css/ js files version!';
# echo -n "Press key:";
# read -n1 ans
# echo -n "Pressed";
# pico ../src/index.html;
# echo -n 'Check Robots.txt: For test and beta add "Diasallow /", for production remove it!';
# echo -n "Press key:";
# read -n1 ans
# pico ../src/robots.txt;
# echo -n "Pressed";
# rm -rf ../src/assets/common-assets/.svn/;
# rm -rf ../src/app/openaireLibrary/.svn/;
# cd ..; npm run build:ssr; cd deploy;
# rm -rf ../src ../node_modules  ../.idea/ ../installOpenaireLib.sh; cd ../; rm -rf deploy;
# echo 'Now copy to the server!'

##<-- to here

#Deploy instructions!
#copy "deploy-folder" in beta.connect.openaire.eu or connect.openaire.eu
#copies of previous deployments exist in  "/home/argiro.kokogiannaki/connect-portal/connectYYYY-MM-DD"
#run "npm i"
#become nodejs user to be able to copy the files: "sudo su nodejs -s /bin/bash"
#check what is running "pm2 list"
#portal files exist in "/srv/www/portal/connect"
#copy deployment files to the portal folder "cp -r /home/argiro.kokogiannaki/connect-portal/connectYYYY-MM-DD/* /srv/www/portal/connect"
#restart portal to get the changes "pm2 restart connect"
