Annotation of openbsd/sxxu/install.sxxu, Revision 1.8
1.6 andrew 1: #!/bin/ksh -
1.8 ! andrew 2: # $Id: install.sxxu,v 1.7 2010/04/20 17:26:00 andrew Exp $
1.4 andrew 3:
4: # Copyright (c) 2010 Andrew Fresh <andrew@afresh1.com>
5: #
6: # Permission to use, copy, modify, and distribute this software for any
7: # purpose with or without fee is hereby granted, provided that the above
8: # copyright notice and this permission notice appear in all copies.
9: #
10: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: #
18: # based on (and some parts taken from) siteXXtools/install.site
19: # Copyright (c) 2006 Alex Holst <a@mongers.org>
20:
1.6 andrew 21: BASEDIR=/var/siteXX
22: user_add_args="-m -gid =uid"
23: [ -e /var/siteXX/siteXXrc ] && . /var/siteXX/siteXXrc
24:
25: export PKG_PATH
26:
27: do_pre() {
28: # nothing to do
29: }
30:
31: do_post() {
32: # nothing to do
33: }
34:
35: process_roles() {
36: local _oldpwd="${PWD}"
37:
38: cd "${BASEDIR}"
39: if [ ! -e roles ]; then
40: echo 'No roles defined.'
41: exit
42: fi
43:
44: local _roles
45: set -A _roles
46: local _role
47: while read _role; do
48: _roles[${#_roles[@]}]="$_role"
49: done < roles
50:
51: for _role in "${_roles[@]}"; do
52: apply_role "$_role"
53: done
1.4 andrew 54:
1.6 andrew 55: cd "${_oldpwd}"
56: }
1.4 andrew 57:
1.6 andrew 58:
59: append_pkg_path() {
60: [ ! -e pkg_path ] && return
61:
62: echo ' ==> Setting PKG_PATH'
1.4 andrew 63: local _line
64: while read _line; do
1.6 andrew 65: if [ -z "${PKG_PATH}" ]; then
66: PKG_PATH="$_line"
67: else
68: PKG_PATH="${PKG_PATH}:${_line}"
69: fi
70: done < pkg_path
71: }
72:
73: run_command_lists() {
74: local _f
75: for _f in *_list; do
76: [ ! -f "${_f}" ] && continue
77:
78: local _cmd=`basename "${_f%_list}"`
79: local _args=`eval echo \\${${_cmd}_args}`
80:
81: echo " ==> Running $_cmd $_args"
82: local _line
83: while read _line; do
84: echo " => ${_line}"
85: eval ${_cmd} ${_args} ${_line}
86: done < ${_f}
87: done
88: }
89:
90: apply_patches() {
91: [ ! -d patches ] && return
92:
93: echo ' ==> Applying patches'
94: local _p
95: for _p in /patches/*; do
96: echo " => $_p"
97: # -N Always assume a forward patch.
98: # -t Never prompt; assume the user is expert
99: # -p0 full path, always
100: patch -N -t -p0 < $_p
101: done
102: }
103:
104: install_packages() {
105: [ ! -d packages ] && return
106:
107: echo ' ==> Installing packages'
108: find packages -name '*.tgz' -print0 | xargs -0 pkg_add ${pkg_add_args}
109: }
110:
111: apply_role() {
112: local _role="$1"
113:
114: if [ ! -d "${_role}" ]; then
115: echo "===> Missing ${_role}"
116: return
117: fi
118:
119: echo "===> Applying ${_role}"
120:
121: local _oldpwd="${PWD}"
122: cd "${_role}"
1.8 ! andrew 123: local _rolepwd="${PWD}"
1.6 andrew 124:
125: if [ -e siteXXrc ]; then
126: echo ' ==> Including siteXXrc'
127: . siteXXrc
128: fi
129:
1.8 ! andrew 130: cd "${_rolepwd}" && append_pkg_path
! 131: cd "${_rolepwd}" && run_command_lists
! 132: cd "${_rolepwd}" && apply_patches
! 133: cd "${_rolepwd}" && install_packages
1.6 andrew 134:
135: if [ -e install.site ]; then
1.8 ! andrew 136: cd "${_rolepwd}"
1.6 andrew 137: if [ -x install.site ]; then
138: echo ' ==> Running install.site'
139: ./install.site
140: else
141: echo ' ==> Including install.site'
142: . install.site
143: fi
144: fi
145:
146: cd "${_oldpwd}"
147: }
148:
149:
150: if [ ! -d "${BASEDIR}" ]; then
151: echo Nothing to do.
152: exit
153: fi
154:
155: do_pre
156: process_roles
157: do_post
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>