Skip to content
Snippets Groups Projects

Add possibility to configure $DFS_WEBSITE_PATH

Merged Alvaro Gonzalez Alvarez requested to merge dfs_allow_any_CI_WEBSITE_DIR into master
All threads resolved!
Files
3
+ 13
43
@@ -7,6 +7,7 @@
# DFS_WEBSITE_PASSWORD
# CI_WEBSITE_DIR => default: public/
# DFS_WEBSITE_NAME
# DFS_WEBSITE_PATH
# SMB_PROTOCOL => default: smb3
#
# Produces:
@@ -42,7 +43,7 @@ then
fi
# Validate input
: "${DFS_WEBSITE_NAME:?DFS_WEBSITE_NAME not provided}"
#: "${DFS_WEBSITE_NAME:?DFS_WEBSITE_NAME not provided}"
: "${DFS_WEBSITE_USERNAME:?DFS_WEBSITE_USERNAME not provided}"
: "${DFS_WEBSITE_PASSWORD:?DFS_WEBSITE_PASSWORD not provided}"
@@ -79,59 +80,28 @@ fi
# If a value is provided for DFS_WEBSITE_DIR (e.g. "mydir") then DFS_WEBSITE_PATH becomes "\Websites\t\test-gitlab-pages\mydir"
# Get the first letter of the website
website_prefix=${DFS_WEBSITE_NAME:0:1}
DFS_WEBSITE_PATH="\Websites\\$website_prefix\\$DFS_WEBSITE_NAME\\$DFS_WEBSITE_DIR"
#
# If the user provides the DFS_WEBSITE_PATH path, use it. Otherwise calculate it
if [ -z $DFS_WEBSITE_PATH ];
then
: "${DFS_WEBSITE_NAME:?DFS_WEBSITE_NAME not provided}"
DFS_WEBSITE_PATH="\Websites\\$website_prefix\\$DFS_WEBSITE_NAME\\$DFS_WEBSITE_DIR"
fi
# Check the target directory in DFS exists and the user has the needed permissions
$smbclient -k //cerndfs.cern.ch/dfs -c "cd $DFS_WEBSITE_PATH"
if [ $? -ne 0 ]
then
echo "ERROR: Failed to access '//cerndfs11/dfs/$DFS_WEBSITE_PATH'"
echo "ERROR: Failed to access '//cerndfs.cern.ch/dfs/$DFS_WEBSITE_PATH'"
exit 1
fi
# TENTATIVE TO KEEP A LIST OF PROTECTED FILES (CONFIG FILES)
# IN ORDER FOR THE DEPLOYER TO DO A FULL SYNC OF THE FILES PRODUCED BY THE USER
# A BACKUP OF THE PROTECTED FILES HAS TO BE DONE, THEN REMOVED EVERYTHING IN DFS
# THEN, RESTORE THE PROTECTED FILES AND FINALLY COPY THE FILES PROVIDED BY THE USER
# WITH SMBCLIENT, THERE IS NOT A SIMPLE WAY TO DO A rm -rf ./website/*
# FOR THE MOMENT JUST OVERIDE WHAT THE USER PROVIDES
# Copy locally the protected files
#if [ -d temp ]
#then
# rm -rf temp
#fi
#mkdir temp
#protected_files=$(echo $DFS_PROTECTED_FILES | tr ":" "\n")
#for file in $protected_files
#do
# $smbclient -k //cerndfs11/dfs -c "lcd temp; cd $DFS_WEBSITE_PATH; prompt OFF; mget $file;"
#done
# Remove everything in DFS
#$smbclient -k //cerndfs11/dfs -c "cd $DFS_WEBSITE_PATH; recurse ON; prompt OFF; mask ""; rmdir *"
#if [ $? -ne 0 ]
#then
# echo ERROR: Failed to delete //cerndfs11/dfs/$DFS_WEBSITE_PATH
# exit 1
#fi
# Restore the protected files
#$smbclient -k //cerndfs11/dfs -c "lcd temp; cd $DFS_WEBSITE_PATH; recurse; prompt OFF; mask *; mput *"
#if [ $? -ne 0 ]
#then
# echo ERROR: Failed to update protected files in //cerndfs11/dfs/$DFS_WEBSITE_PATH
# exit 1
#fi
# Copy the contents to the folder specified
$smbclient -k //cerndfs11/dfs -c "lcd $CI_WEBSITE_DIR; cd $DFS_WEBSITE_PATH; recurse; prompt OFF; mask *; mput *"
$smbclient -k //cerndfs.cern.ch/dfs -c "lcd $CI_WEBSITE_DIR; cd $DFS_WEBSITE_PATH; recurse; prompt OFF; mask *; mput *"
if [ $? -ne 0 ]
then
echo "ERROR: Failed to update '//cerndfs11/dfs/$DFS_WEBSITE_PATH'"
echo "ERROR: Failed to update '//cerndfs.cern.ch/dfs/$DFS_WEBSITE_PATH'"
exit 1
fi
Loading