Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
deployer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Sistemisti
deployer
Commits
01a85736
Commit
01a85736
authored
Nov 18, 2020
by
Mattia Rizzolo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move code under a subshell
Signed-off-by:
Mattia Rizzolo
<
mapreri@ubuntu.com
>
parent
fb685486
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
cron.sh
cron.sh
+12
-9
No files found.
cron.sh
View file @
01a85736
...
@@ -10,15 +10,14 @@ if [[ "$(whoami)" != "ubuntu-it" ]]; then
...
@@ -10,15 +10,14 @@ if [[ "$(whoami)" != "ubuntu-it" ]]; then
exit
1
exit
1
fi
fi
run_script
()
(
# Try to deploy all the websites
for
script
in
"
${
base
}
/scripts/"
*
;
do
if
[[
!
-x
"
${
script
}
"
]]
;
then
if
[[
!
-x
"
${
script
}
"
]]
;
then
continue
echo
"
$(
basename
"
$script
"
)
: not executable, skipping"
return
fi
fi
# Create a temporary build directory
# Create a temporary build directory
build_dir
=
"
$(
mktemp
-d
deploy-XXXXXXXXX
-p
/tmp
)
"
build_dir
=
"
$(
mktemp
-d
deploy-XXXXXXXXX
-p
/tmp
)
"
trap
'rm -rfv "$build_dir"'
RETURN
# Switch to the temporary build directory
# Switch to the temporary build directory
cd
"
${
build_dir
}
"
cd
"
${
build_dir
}
"
...
@@ -29,8 +28,10 @@ for script in "${base}/scripts/"*; do
...
@@ -29,8 +28,10 @@ for script in "${base}/scripts/"*; do
# Execute the deploy script
# Execute the deploy script
# Capture the output and print it only if the script fails
# Capture the output and print it only if the script fails
"
$script
"
>
"
$output
"
"
$script
"
>
"
$output
"
if
[[
$?
-ne
0
]]
;
then
ret
=
$?
if
[[
"
$ret
"
-ne
0
]]
;
then
echo
"Deploy script
$(
basename
"
${
script
}
"
)
failed!"
echo
"Deploy script
$(
basename
"
${
script
}
"
)
failed!"
echo
"Return code:
$?
"
echo
"Script output"
echo
"Script output"
echo
"============="
echo
"============="
cat
"
${
output
}
"
cat
"
${
output
}
"
...
@@ -40,8 +41,10 @@ for script in "${base}/scripts/"*; do
...
@@ -40,8 +41,10 @@ for script in "${base}/scripts/"*; do
# Restore the old home
# Restore the old home
cd
"
${
base
}
"
cd
"
${
base
}
"
export
HOME
=
"
${
base
}
"
export
HOME
=
"
${
base
}
"
)
# Remove the temporary directory
rm
-rf
"
${
build_dir
}
"
done
# Try to deploy all the websites
for
script
in
"
${
base
}
/scripts/"
*
;
do
run_script
"
$script
"
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment