-
Notifications
You must be signed in to change notification settings - Fork 278
/
Copy pathafter_install
31 lines (26 loc) · 1.28 KB
/
after_install
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
#!/usr/bin/env bash
# rvm after_install hook to provide selinux support
# This script will make sure the correct selinux contexts are set on ruby
# files after each ruby version install.
# WARNING - As of 2012-02-08, there is a bug in current versions
# of rvm (now 1.10.2) such that it cannot find this after_install hook
# See rvm issues #744 and #745 on github for more information
if [ $EUID -ne 0 ]; then
# Don't try to mess with selinux if we are not root
exit
fi
if [ ! \( -x /usr/sbin/semanage -a -x /sbin/restorecon \) ]; then
echo "SELinux executables missing, rvm after_install hook failed"
exit 1
fi
# Set up rvm file context patterns if they are not already present
# This will handle installs in either /usr/local/rvm or /usr/lib/rvm
semanage fcontext -l | /bin/grep -q rvm || {
semanage fcontext -a -t bin_t '/usr/(local|lib)/rvm/wrappers(/.*)?'
semanage fcontext -a -t bin_t '/usr/(local|lib)/rvm/rubies/ruby-.*/bin(/.*)?'
semanage fcontext -a -t lib_t '/usr/(local|lib)/rvm/rubies/ruby-.*/lib(/.*)?'
semanage fcontext -a -t lib_t '/usr/(local|lib)/rvm/gems(/.*)?'
semanage fcontext -a -t passenger_exec_t '/usr/(local|lib)/rvm/gems/ruby-.*/gems/passenger-.*/agents/(apache2/)?Passenger.*'
}
# Run restorecon on the rvm hierarchy to fix the contexts
restorecon -R $rvm_path