From 41c32f9c525b5b5a4b44bd7a685eb4e46015a9c4 Mon Sep 17 00:00:00 2001 From: acinonyx Date: Mon, 7 Jan 2013 12:01:11 +0000 Subject: [package] zram-swap: Install init script with 0755 mode git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35033 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/zram-swap/Makefile | 6 +- package/zram-swap/files/etc/init.d/zram | 123 -------------------------------- package/zram-swap/files/zram.init | 123 ++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 126 deletions(-) delete mode 100755 package/zram-swap/files/etc/init.d/zram create mode 100644 package/zram-swap/files/zram.init (limited to 'package/zram-swap') diff --git a/package/zram-swap/Makefile b/package/zram-swap/Makefile index 59a55c477..bded5f380 100644 --- a/package/zram-swap/Makefile +++ b/package/zram-swap/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=zram-swap PKG_VERSION:=1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -39,8 +39,8 @@ define Build/Compile endef define Package/zram-swap/install - $(INSTALL_DIR) $(1) - $(CP) ./files/* $(1)/ + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/zram.init $(1)/etc/init.d/zram endef $(eval $(call BuildPackage,zram-swap)) diff --git a/package/zram-swap/files/etc/init.d/zram b/package/zram-swap/files/etc/init.d/zram deleted file mode 100755 index 23de915c8..000000000 --- a/package/zram-swap/files/etc/init.d/zram +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=15 - -ram_size() -{ - local line - - while read line; do case "$line" in MemTotal:*) set $line; echo "$2"; break ;; esac; done /dev/null || { - logger -s -t zram_applicable -p daemon.err "[ERROR] 'mkswap' not installed" - return 1 - } - - which swapon >/dev/null || { - logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapon' not installed" - return 1 - } - - which swapoff >/dev/null || { - logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapoff' not installed" - return 1 - } -} - -zram_dev() -{ - local core="$1" - - echo "/dev/zram${core:-0}" -} - -zram_reset() -{ - local dev="$1" - local message="$2" - local proc_entry="/sys/block/$( basename "$dev" )/reset" - - logger -s -t zram_reset -p daemon.debug "$message via $proc_entry" - echo "1" >"$proc_entry" -} - -list_cpu_idx() -{ - local line i=0 - - while read line; do { - case "$line" in - [Pp]rocessor*) - echo $i - i=$(( $i + 1 )) - ;; - esac - } done <"/proc/cpuinfo" -} - -start() -{ - # http://shmilyxbq-compcache.googlecode.com/hg/README - # if >1 cpu_core, reinit kmodule with e.g. num_devices=4 - - local zram_size="$( zram_size )" - local zram_dev core - - for core in $( list_cpu_idx ); do { - zram_dev="$( zram_dev "$core" )" - zram_applicable "$zram_dev" || return 1 - - logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)" - - zram_reset "$zram_dev" "enforcing defaults" - echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename $zram_dev )/disksize" - mkswap "$zram_dev" - swapon "$zram_dev" - } done -} - -stop() -{ - local zram_dev proc_entry - - for core in $( list_cpu_idx ); do { - zram_dev="$( zram_dev "$core" )" - proc_entry="/sys/block/$( basename "$zram_dev" )/reset" - - grep -sq ^"$zram_dev " /proc/swaps && { - logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev" - swapoff "$zram_dev" - } - - zram_reset "$zram_dev" "claiming memory back" - } done -} - diff --git a/package/zram-swap/files/zram.init b/package/zram-swap/files/zram.init new file mode 100644 index 000000000..23de915c8 --- /dev/null +++ b/package/zram-swap/files/zram.init @@ -0,0 +1,123 @@ +#!/bin/sh /etc/rc.common + +START=15 + +ram_size() +{ + local line + + while read line; do case "$line" in MemTotal:*) set $line; echo "$2"; break ;; esac; done /dev/null || { + logger -s -t zram_applicable -p daemon.err "[ERROR] 'mkswap' not installed" + return 1 + } + + which swapon >/dev/null || { + logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapon' not installed" + return 1 + } + + which swapoff >/dev/null || { + logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapoff' not installed" + return 1 + } +} + +zram_dev() +{ + local core="$1" + + echo "/dev/zram${core:-0}" +} + +zram_reset() +{ + local dev="$1" + local message="$2" + local proc_entry="/sys/block/$( basename "$dev" )/reset" + + logger -s -t zram_reset -p daemon.debug "$message via $proc_entry" + echo "1" >"$proc_entry" +} + +list_cpu_idx() +{ + local line i=0 + + while read line; do { + case "$line" in + [Pp]rocessor*) + echo $i + i=$(( $i + 1 )) + ;; + esac + } done <"/proc/cpuinfo" +} + +start() +{ + # http://shmilyxbq-compcache.googlecode.com/hg/README + # if >1 cpu_core, reinit kmodule with e.g. num_devices=4 + + local zram_size="$( zram_size )" + local zram_dev core + + for core in $( list_cpu_idx ); do { + zram_dev="$( zram_dev "$core" )" + zram_applicable "$zram_dev" || return 1 + + logger -s -t zram_start -p daemon.debug "activating '$zram_dev' for swapping ($zram_size MegaBytes)" + + zram_reset "$zram_dev" "enforcing defaults" + echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename $zram_dev )/disksize" + mkswap "$zram_dev" + swapon "$zram_dev" + } done +} + +stop() +{ + local zram_dev proc_entry + + for core in $( list_cpu_idx ); do { + zram_dev="$( zram_dev "$core" )" + proc_entry="/sys/block/$( basename "$zram_dev" )/reset" + + grep -sq ^"$zram_dev " /proc/swaps && { + logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev" + swapoff "$zram_dev" + } + + zram_reset "$zram_dev" "claiming memory back" + } done +} + -- cgit v1.2.3