Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pkg-varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
pkg-varnish-cache
Commits
c0729f16
Commit
c0729f16
authored
Mar 21, 2017
by
Dridi Boukelmoune
Committed by
Denis Brækhus
Oct 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First bash at a unified reload script
parent
05fc0e44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
varnishreload
varnishreload
+85
-0
No files found.
varnishreload
0 → 100755
View file @
c0729f16
#!/bin/sh
set
-e
set
-u
WORK_DIR
=
VCL_FILE
=
WARMUP
=
varnishadm
()
{
if
!
OUTPUT
=
"
$(
command
varnishadm
-n
"
$WORK_DIR
"
--
"
$@
"
2>&1
)
"
then
echo
"Command: varnishadm -n '
$WORK_DIR
' --
$*
"
echo
echo
"
$OUTPUT
"
echo
exit
1
fi
>
&2
echo
"
$OUTPUT
"
}
fail
()
{
echo
"Error:
$*
"
>
&2
exit
1
}
vcl_count
()
{
varnishadm vcl.list |
awk
"BEGIN {n=0}
\$
NF ==
\"
$1
\"
{n=n+1} END {print n}"
}
vcl_file
()
{
if
!
VCL_SHOW
=
"
$(
varnishadm vcl.show
-v
"
$1
"
)
"
then
fail
"failed to get the VCL file name"
fi
echo
"
$VCL_SHOW
"
|
awk
'NR == 1 {print $NF}'
}
vcl_active_name
()
{
if
!
VCL_LIST
=
"
$(
varnishadm vcl.lists
)
"
then
fail
"failed to get the active VCL name"
fi
echo
"
$VCL_LIST
"
|
awk
'/^active/ {print $NF}'
}
vcl_active_file
()
{
set
-e
VCL_NAME
=
$(
vcl_active_name
)
VCL_COUNT
=
$(
vcl_count
"
$VCL_NAME
"
)
# XXX: it can happen with a discard but I haven't checked whether it
# actually messes with vcl.show (I suspect we don't need this).
test
"
$VCL_COUNT
"
-gt
1
&&
fail
"more than one VCL named
$VCL_NAME
(
$VCL_COUNT
)"
vcl_file
"
$VCL_NAME
"
}
vcl_reload_name
()
{
printf
"reload_%s"
"
$(
date
+%Y%m%dT%H%M%S
)
"
}
# TODO: getopts for -n only, if any (probably without heavy-handed getopts)
# TODO: get VCL_FILE from first (and only) non-opt argument, if any
if
[
-z
"
$VCL_FILE
"
]
then
VCL_FILE
=
$(
vcl_active_file
)
case
$VCL_FILE
in
/
*
)
;;
*
)
fail
"active VCL file not found (got
$VCL_FILE
)"
;;
esac
fi
RELOAD_NAME
=
$(
vcl_reload_name
)
varnishadm vcl.load
"
$RELOAD_NAME
"
"
$VCL_FILE
"
# TODO: warmup pause
varnishadm vcl.use
"
$RELOAD_NAME
"
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