Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add centos support #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true
driver:
name: vagrant

provisioner:
name: chef_zero

verifier:
name: inspec

platforms:
- name: ubuntu-12.04
driver_config:
box: opscode-ubuntu-12.04
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
- name: ubuntu-10.04
driver_config:
box: opscode-ubuntu-10.04
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box
- name: centos-6.4
driver_config:
box: opscode-centos-6.4
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
- name: centos-5.9
driver_config:
box: opscode-centos-5.9
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box
- name: debian-7.8
- name: ubuntu-10.04
- name: ubuntu-12.04
- name: ubuntu-14.04
- name: ubuntu-15.10
- name: centos-6.7
- name: centos-7.2

suites:
- name: default
run_list: []
attributes: {}
run_list:
- recipe[sysfs-test]
6 changes: 5 additions & 1 deletion Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
site :opscode
source 'https://supermarket.chef.io'

metadata

group :test do
cookbook 'sysfs-test', path: './test/cookbooks/sysfs-test'
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Attributes
Usage
=====

With Ressource/Provider.
With Resource/Provider.

Resource/Provider
=================
Expand All @@ -34,7 +34,7 @@ sysfs
sysfs 'block/sda/queue/scheduler' do
value 'noop'
end

# the same.
sysfs 'set io scheduler to cfq' do
variable 'block/sda/queue/scheduler'
Expand Down
86 changes: 0 additions & 86 deletions Vagrantfile

This file was deleted.

1 change: 0 additions & 1 deletion attributes/default.rb

This file was deleted.

51 changes: 0 additions & 51 deletions file_edit_patch.rb

This file was deleted.

22 changes: 22 additions & 0 deletions files/default/sysfs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# /etc/sysfs.conf - Configuration file for setting sysfs attributes.
#
# The sysfs mount directory is automatically prepended to the attribute paths.
#
# Syntax:
# attribute = value
# mode attribute = 0600 # (any valid argument for chmod)
# owner attribute = root:wheel # (any valid argument for chown)
#
# Examples:
#
# Always use the powersave CPU frequency governor
# devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
#
# Use userspace CPU frequency governor and set initial speed
# devices/system/cpu/cpu0/cpufreq/scaling_governor = userspace
# devices/system/cpu/cpu0/cpufreq/scaling_setspeed = 600000
#
# Set permissions of suspend control file
# mode power/state = 0660
# owner power/state = root:power
147 changes: 147 additions & 0 deletions files/default/sysfsutils
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#! /bin/sh -e

### BEGIN INIT INFO
# Provides: sysfsconf
# Required-Start: mountkernfs
# Should-Start: udev module-init-tools cpufrequtils
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Set sysfs variables from /etc/sysfs.conf
# Description: Similarly to /etc/init.d/procps.sh, you can configure
# values for sysfs variables (such as power management
# defaults) and /sys file permissions in /etc/sysfs.conf.
### END INIT INFO

# /etc/init.d/sysfsutils:
#
# (c) 2005 Martin Pitt <[email protected]>

CONFFILE=/etc/sysfs.conf
CONFDIR=/etc/sysfs.d

[ -r "$CONFFILE" -o -d "$CONFDIR" ] || exit 0

# RHEL does not have the init-functions file, so lets copy what we need
#. /lib/lsb/init-functions
log_begin_msg () {
if [ -z "${1:-}" ]; then
return 1
fi
echo -n "$@"
}

log_failure_msg () {
if [ -n "${1:-}" ]; then
log_begin_msg $@ "..."
fi
log_end_msg 1 || true
}

log_end_msg_pre () { :; }
log_end_msg_post () { :; }

log_use_fancy_output () {
TPUT=/usr/bin/tput
EXPR=/usr/bin/expr
if [ -t 1 ] && [ "x${TERM:-}" != "x" ] && [ "x${TERM:-}" != "xdumb" ] && [ -x $TPUT ] && [ -x $EXPR ] && $TPUT hpa 60 >/dev/null 2>&1 && $TPUT setaf 1 >/dev/null 2>&1; then
[ -z $FANCYTTY ] && FANCYTTY=1 || true
else
FANCYTTY=0
fi
case "$FANCYTTY" in
1|Y|yes|true) true;;
*) false;;
esac
}

# int log_end_message (int exitstatus)
log_end_msg () {
# If no arguments were passed, return
if [ -z "${1:-}" ]; then
return 1
fi

retval=$1

log_end_msg_pre "$@"

# Only do the fancy stuff if we have an appropriate terminal
# and if /usr is already mounted
if log_use_fancy_output; then
RED=`$TPUT setaf 1`
YELLOW=`$TPUT setaf 3`
NORMAL=`$TPUT op`
else
RED=''
YELLOW=''
NORMAL=''
fi

if [ $1 -eq 0 ]; then
echo "."
elif [ $1 -eq 255 ]; then
/bin/echo -e " ${YELLOW}(warning).${NORMAL}"
else
/bin/echo -e " ${RED}failed!${NORMAL}"
fi
log_end_msg_post "$@"
return $retval
}

# End of copy

load_conffile() {
FILE="$1"
sed 's/#.*$//; /^[[:space:]]*$/d;
s/^[[:space:]]*\([^=[:space:]]*\)[[:space:]]*\([^=[:space:]]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1 \2 \3/' \
$FILE | {
while read f1 f2 f3; do
if [ "$f1" = "mode" -a -n "$f2" -a -n "$f3" ]; then
if [ -f "/sys/$f2" ] || [ -d "/sys/$f2" ]; then
chmod "$f3" "/sys/$f2"
else
log_failure_msg "unknown attribute $f2"
fi
elif [ "$f1" = "owner" -a -n "$f2" -a -n "$f3" ]; then
if [ -f "/sys/$f2" ]; then
chown "$f3" "/sys/$f2"
else
log_failure_msg "unknown attribute $f2"
fi
elif [ "$f1" -a -n "$f2" -a -z "$f3" ]; then
if [ -f "/sys/$f1" ]; then
# Some fields need a terminating newline, others
# need the terminating newline to be absent :-(
echo -n "$f2" > "/sys/$f1" 2>/dev/null ||
echo "$f2" > "/sys/$f1"
else
log_failure_msg "unknown attribute $f1"
fi
else
log_failure_msg "syntax error in $CONFFILE: '$f1' '$f2' '$f3'"
log_end_msg 1
exit 1
fi
done
}
}

case "$1" in
start|restart|force-reload)
log_begin_msg "Setting sysfs variables..."

for file in $CONFFILE $CONFDIR/*.conf; do
[ -r "$file" ] || continue
load_conffile "$file"
done

log_end_msg 0
;;
stop)
;;
*)
echo "Usage: /etc/init.d/sysfsutils {start|stop|force-reload|restart}"
exit 1
;;
esac
Loading