-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_puppet_modules.sh
executable file
·73 lines (64 loc) · 1.92 KB
/
update_puppet_modules.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#
# Garrett Honeycutt - code@garretthoneycutt.com - copyright 2013
#
# Licensed under Apache Software License v2.0
#
# This script is meant to work with librarian-puppet-simple. It is a simple
# wrapper script that validates the Puppetfile, initiates
# librarian-puppet-simple, and restarts the puppet master.
#
# /~https://github.com/bodepd/librarian-puppet-simple
# librarian-puppet-simple can be installed from source or with
# `gem install librarian-puppet-simple`
#
LIBRARIAN_DIR=/var/local/local-modules
LIBRARIAN_DIR_TMP=modules-tmp
PUPPETFILE=${LIBRARIAN_DIR}/Puppetfile
LIBRARIAN_PUPPET=librarian-puppet
LIBRARIAN_PUPPET_FLAGS='--verbose'
VALIDATION_CMD="ruby -c ${PUPPETFILE}"
CLEAN_CMD="${LIBRARIAN_PUPPET} clean ${LIBRARIAN_PUPPET_FLAGS}"
CLEAN_CMD_DIR_TMP="${CLEAN_CMD} --path=${LIBRARIAN_DIR_TMP}"
INSTALL_CMD="${LIBRARIAN_PUPPET} install ${LIBRARIAN_PUPPET_FLAGS} --path=${LIBRARIAN_DIR_TMP}"
if [ -d $LIBRARIAN_DIR ]; then
cd $LIBRARIAN_DIR
else
echo "LIBRARIAN_DIR (${LIBRARIAN_DIR}) does not exist."
exit 1
fi
if [ ! -r $PUPPETFILE ]; then
echo "PUPPETFILE (${PUPPETFILE}) does not exist or is not readable."
exit 2
fi
$VALIDATION_CMD
if [ $? != 0 ]; then
echo "Validating Puppetfile with (${VALIDATION_CMD}) did not exit successfully."
exit 6
fi
$CLEAN_CMD_DIR_TMP
if [ $? != 0 ]; then
echo "Cleaning the temporary library with (${CLEAN_CMD_DIR_TMP}) did not exit successfully."
exit 3
fi
$INSTALL_CMD
if [ $? != 0 ]; then
echo "Installing the library with (${INSTALL_CMD}) did not exit successfully."
exit 4
fi
$CLEAN_CMD
if [ $? != 0 ]; then
echo "Cleaning the library with (${CLEAN_CMD}) did not exit successfully."
exit 7
fi
mv $LIBRARIAN_DIR_TMP modules
if [ $? != 0 ]; then
echo "Rename of temporary download directory (${LIBRARIAN_DIR_TMP}) to modules failed."
exit 8
fi
service httpd restart
if [ $? != 0 ]; then
echo "Restarting httpd did not exit successfully."
exit 5
fi
exit 0