forked from gboudreau/Greyhole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreyhole.spec
228 lines (194 loc) · 9.91 KB
/
greyhole.spec
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
Name: greyhole
Version: $VERSION
Release: $BUILD_NUMBER
Summary: Greyhole is a drive pooling technology for Samba
Group: System Environment/Daemons
Source: http://greyhole.googlecode.com/files/%{name}-%{version}.tar.gz
License: GPL
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: samba >= 3.4.3, php-cli >= 5, php-pdo, php-mysql, php-mbstring, php-intl, rsync, sysstat, lsof
%description
Greyhole allows you to create a storage pool, accessible from
Samba shares, that offers data redundancy and JBOD concatenation.
%define debug_package %{nil}
%prep
%setup -q
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT/usr/share/greyhole/web-app/
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1/
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man5/
install -m 0755 -D -p greyhole ${RPM_BUILD_ROOT}%{_bindir}
install -m 0755 -D -p greyhole-dfree ${RPM_BUILD_ROOT}%{_bindir}
install -m 0755 -D -p greyhole-dfree.php ${RPM_BUILD_ROOT}/usr/share/greyhole/
install -m 0755 -D -p greyhole-custom-cp.sh ${RPM_BUILD_ROOT}/usr/share/greyhole/
install -m 0644 -D -p schema-mysql.sql ${RPM_BUILD_ROOT}/usr/share/greyhole/
install -m 0644 -D -p schema-sqlite.sql ${RPM_BUILD_ROOT}/usr/share/greyhole/
install -m 0755 -D -p db_migration-sqlite2mysql.sh ${RPM_BUILD_ROOT}/usr/share/greyhole/
install -m 0644 -D -p greyhole.example.conf ${RPM_BUILD_ROOT}/usr/share/greyhole/
install -m 0644 -D -p greyhole.example.conf ${RPM_BUILD_ROOT}%{_sysconfdir}/greyhole.conf
install -m 0755 -D -p initd_script.sh ${RPM_BUILD_ROOT}/etc/rc.d/init.d/greyhole
install -m 0644 -D -p logrotate.greyhole ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/greyhole
install -m 0644 -D -p greyhole.cron.d ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.d/greyhole
install -m 0755 -D -p greyhole.cron.weekly ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.weekly/greyhole
install -m 0755 -D -p greyhole.cron.daily ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.daily/greyhole
install -m 0644 -D -p web-app/index.php ${RPM_BUILD_ROOT}/usr/share/greyhole/web-app/
install -m 0644 -D -p web-app/README ${RPM_BUILD_ROOT}/usr/share/greyhole/web-app/
install -m 0644 -D -p USAGE ${RPM_BUILD_ROOT}/usr/share/greyhole/
install -m 0644 -D -p docs/greyhole.1.gz ${RPM_BUILD_ROOT}/usr/share/man/man1/
install -m 0644 -D -p docs/greyhole-dfree.1.gz ${RPM_BUILD_ROOT}/usr/share/man/man1/
install -m 0644 -D -p docs/greyhole.conf.5.gz ${RPM_BUILD_ROOT}/usr/share/man/man5/
%ifarch x86_64
install -m 0644 -D -p samba-module/bin/3.4/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba34.so
install -m 0644 -D -p samba-module/bin/3.5/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba35.so
install -m 0644 -D -p samba-module/bin/3.6/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba36.so
install -m 0644 -D -p samba-module/bin/4.0/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba40.so
install -m 0644 -D -p samba-module/bin/4.1/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba41.so
install -m 0644 -D -p samba-module/bin/4.2/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba42.so
install -m 0644 -D -p samba-module/bin/4.3/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba43.so
install -m 0644 -D -p samba-module/bin/4.4/greyhole-x86_64.so ${RPM_BUILD_ROOT}/usr/lib64/greyhole/greyhole-samba44.so
%else
%ifarch %{arm}
install -m 0644 -D -p samba-module/bin/3.4/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba34.so
install -m 0644 -D -p samba-module/bin/3.5/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba35.so
#install -m 0644 -D -p samba-module/bin/3.6/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba36.so # Not available yet
#install -m 0644 -D -p samba-module/bin/4.0/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba40.so # Not available yet
#install -m 0644 -D -p samba-module/bin/4.1/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba41.so # Not available yet
#install -m 0644 -D -p samba-module/bin/4.2/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba42.so # Not available yet
#install -m 0644 -D -p samba-module/bin/4.3/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba43.so # Not available yet
#install -m 0644 -D -p samba-module/bin/4.4/greyhole-armv5tel.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba44.so # Not available yet
%else
install -m 0644 -D -p samba-module/bin/3.4/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba34.so
install -m 0644 -D -p samba-module/bin/3.5/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba35.so
install -m 0644 -D -p samba-module/bin/3.6/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba36.so
install -m 0644 -D -p samba-module/bin/4.0/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba40.so
install -m 0644 -D -p samba-module/bin/4.1/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba41.so
install -m 0644 -D -p samba-module/bin/4.2/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba42.so
install -m 0644 -D -p samba-module/bin/4.3/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba43.so
install -m 0644 -D -p samba-module/bin/4.4/greyhole-i386.so ${RPM_BUILD_ROOT}/usr/lib/greyhole/greyhole-samba44.so
%endif
%endif
%clean
rm -rf $RPM_BUILD_ROOT
%pre
%post
echo "Executing post-install script..."
mkdir -p /var/spool/greyhole
chmod 777 /var/spool/greyhole
/usr/bin/greyhole --create-mem-spool >/dev/null
mkdir -p /var/cache/greyhole-dfree
chmod 777 /var/cache/greyhole-dfree
if [ -d /usr/lib/x86_64-linux-gnu ]; then
SOURCE_LIBDIR="/usr/lib64"
TARGET_LIBDIR="/usr/lib/x86_64-linux-gnu"
elif [ "`uname -m`" = "x86_64" ]; then
SOURCE_LIBDIR="/usr/lib64"
TARGET_LIBDIR="/usr/lib64"
else
SOURCE_LIBDIR="/usr/lib"
TARGET_LIBDIR="/usr/lib"
fi
TARGET_SYMLINK="${TARGET_LIBDIR}/samba/vfs/greyhole.so"
SMB_VERSION="`smbd --version | awk '{print $2}' | awk -F'-' '{print $1}' | awk -F'.' '{print $1,$2}'`"
if [ "${SMB_VERSION}" = "3 4" ]; then
LIB_FILE="greyhole-samba34.so"
elif [ "${SMB_VERSION}" = "3 5" ]; then
LIB_FILE="greyhole-samba35.so"
elif [ "${SMB_VERSION}" = "3 6" ]; then
LIB_FILE="greyhole-samba36.so"
elif [ "${SMB_VERSION}" = "4 0" ]; then
LIB_FILE="greyhole-samba40.so"
elif [ "${SMB_VERSION}" = "4 1" ]; then
LIB_FILE="greyhole-samba41.so"
elif [ "${SMB_VERSION}" = "4 2" ]; then
LIB_FILE="greyhole-samba42.so"
elif [ "${SMB_VERSION}" = "4 3" ]; then
LIB_FILE="greyhole-samba43.so"
elif [ "${SMB_VERSION}" = "4 4" ]; then
LIB_FILE="greyhole-samba44.so"
else
echo "Warning: Greyhole doesn't include a VFS module for your version of Samba (${SMB_VERSION})."
echo "We will try to use the VFS for Samba 4.4, but that might not work."
LIB_FILE="greyhole-samba44.so"
fi
SOURCE_LIB="${SOURCE_LIBDIR}/greyhole/${LIB_FILE}"
rm -f ${TARGET_SYMLINK}
ln -s ${SOURCE_LIB} ${TARGET_SYMLINK}
if [ -f /proc/fs/cifs/OplockEnabled ]; then
# cifs client workaround
# Ref: http://blog.dhampir.no/content/cifs-vfs-no-response-for-cmd-n-mid
modprobe cifs
echo 0 > /proc/fs/cifs/OplockEnabled
fi
if [ -f /sys/module/cifs/parameters/enable_oplocks ]; then
# cifs client workaround
# Ref: http://blog.dhampir.no/content/cifs-vfs-no-response-for-cmd-n-mid
modprobe cifs enable_oplocks=0
echo 0 > /sys/module/cifs/parameters/enable_oplocks
fi
running=0
# (SYSV) Service install & start
if [ -f /sbin/chkconfig ]; then
/sbin/chkconfig --add greyhole
/sbin/chkconfig greyhole on
else
/usr/sbin/update-rc.d greyhole defaults
fi
if [ -f /etc/rc.d/init.d/greyhole ]; then
if [ "`service greyhole stat 2> /dev/null | grep 'is running' | wc -l`" = "1" ]; then
service greyhole restart
running=1
fi
fi
if [ $running -eq 0 ]; then
echo "==========================================================================="
echo "See /usr/share/greyhole/USAGE to learn how to configure and start Greyhole."
echo "==========================================================================="
fi
man logrotate > /dev/null 2>&1 || echo "Warning! logrotate is not installed. You should install logrotate to make sure the Greyhole logs don't fill your root partition.
Greyhole already installed the necessary conf file for logrotate; simply installing the logrotate package is enough."
%preun
# Delete VFS module symlinks, if any
rm -f /usr/lib/x86_64-linux-gnu/samba/vfs/greyhole.so
rm -f /usr/lib64/samba/vfs/greyhole.so
rm -f /usr/lib/samba/vfs/greyhole.so
# Delete cache folder
rm -rf /var/cache/greyhole-dfree
if [ "$1" != 0 ]; then
/sbin/service greyhole condrestart 2>&1 > /dev/null
else
# not an update, a complete uninstall
# Service removal
/sbin/service greyhole stop 2>&1 > /dev/null
/sbin/chkconfig --del greyhole
# Remove Greyhole from /etc/samba/smb.conf
grep -v "dfree.*greyhole" /etc/samba/smb.conf > /etc/samba/smb.conf.new
sed --in-place -e 's@\(vfs objects.*\) greyhole@\1@' /etc/samba/smb.conf.new
sed --in-place -e 's@^[ \t]*vfs objects =$@@' /etc/samba/smb.conf.new
mv -f /etc/samba/smb.conf.new /etc/samba/smb.conf
/sbin/service smb reload 2>&1 > /dev/null
fi
%files
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/greyhole.conf
/etc/rc.d/init.d/greyhole
/etc/*/greyhole*
/usr/bin/greyhole*
%{_libdir}/greyhole/
/usr/share/greyhole/
/usr/share/man/*/greyhole*
%changelog
* Sun Jan 13 2013 Guillaume Boudreau
- Including gh-du web UI
* Sun Jan 02 2011 Guillaume Boudreau
- Fedora 14 (Samba 3.5) compatibility fixes
* Mon Mar 29 2010 Carlos Puchol
- add sqlite schema file, rename mysql one
- use /usr/share/greyhole instead of local
* Mon Feb 22 2010 Guillaume Boudreau
- major update in all sections; more automated installation
* Wed Jan 22 2010 Carlos Puchol
- initial version of Greyhole spec