-
Notifications
You must be signed in to change notification settings - Fork 2
/
partition.AP-server
executable file
·69 lines (54 loc) · 2.38 KB
/
partition.AP-server
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
#!/bin/bash
# git://github.com/aswen/scripts.git mk_partitions
# maakt partities op database server en maakt ook raid arrays
# Copyright (C) 2014-2015 Alexander Swen <alex@swen.nu>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Alexander Swen
# Private contact: alex@swen.nu
# CHANGELOG:
# 2011-03-30 A.Swen created.
# 2011-04-06 A.Swen removed some bugs (order in which filesystems where created in make_os_drives function).
# 2011-04-14 A.Swen removed all but hpacucli things because of problems with partitions and grub...
# SETTINGS
date=$(date +%Y%m%d)
me=$(basename $0)
mydir=$(dirname $0)
hn=$(hostname)
# FUNCTIONS
die () {
rc=$1
shift
echo "==========================">&2
echo "==== FATAL ERROR ====" >&2
echo "==========================">&2
echo "" >&2
echo $@ >&2
exit $rc
}
comment () {
echo; echo "$(date) ${me}@${hn} $1"
}
init_array_cfg=/tmp/fai/init_array_cfg
init_array_cfg_simple=/tmp/fai/init_array_cfg_simple
array_slot=$(hpacucli ctrl all show|awk '/Smart Array/ {print $6}')
comment "One disk box found on HP Array controller in slot ${array_slot}. This must be an application server..."
mirror_drives=$(grep -A10 unassigned ${init_array_cfg_simple}|grep physicaldrive|head -2|awk '{printf $2",";}; END{print ;}'|sed -e 's/,$//g')
spare_drive=$(grep -A10 unassigned ${init_array_cfg_simple}|grep physicaldrive|tail -1|awk '{print $2}')
comment "Creating a raid 1 array using disks ${mirror_drives}"
hpacucli ctrl slot=${array_slot} create type=ld drives=${mirror_drives} raid=1 ss=256 sectors=32 aa=enable
comment "Adding drive ${spare_drive} to the mirror array"
hpacucli ctrl slot=${array_slot} array b add spares=${spare_drive}
comment "Refreshing the ${init_array_cfg_simple} file"
hpacucli ctrl slot=${array_slot} show config > ${init_array_cfg_simple}
comment "Finished";echo
# END