Tidying zram

This commit is contained in:
Bob Mottram 2018-02-25 11:27:48 +00:00
parent 94053f6bed
commit ad8d266452
2 changed files with 27 additions and 28 deletions

View File

@ -28,9 +28,9 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
DEFAULT_LANGUAGE=$(echo $LANG) DEFAULT_LANGUAGE=$LANG
if [ ! $PROJECT_NAME ]; then if [ ! "$PROJECT_NAME" ]; then
PROJECT_NAME='freedombone' PROJECT_NAME='freedombone'
fi fi
@ -81,24 +81,24 @@ ENABLE_SOCIAL_KEY_MANAGEMENT="no"
SOCIALINSTANCE= SOCIALINSTANCE=
# include utils # include utils
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* UTILS_FILES="/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*"
for f in $UTILS_FILES for f in $UTILS_FILES
do do
source $f source "$f"
done done
# include base system apps # include base system apps
BASE_SYSTEM_FILES=/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-* BASE_SYSTEM_FILES="/usr/share/${PROJECT_NAME}/base/${PROJECT_NAME}-base-*"
for f in $BASE_SYSTEM_FILES for f in $BASE_SYSTEM_FILES
do do
source $f source "$f"
done done
#include apps #include apps
APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-* APP_FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*"
for f in $APP_FILES for f in $APP_FILES
do do
source $f source "$f"
done done
# optionally specify your name to appear on the blog # optionally specify your name to appear on the blog

View File

@ -36,20 +36,19 @@ export TEXTDOMAINDIR="/usr/share/locale"
DAEMON_FILENAME=/etc/systemd/system/zram.service DAEMON_FILENAME=/etc/systemd/system/zram.service
function zram_daemon { function zram_daemon {
echo '[Unit]' > $DAEMON_FILENAME { echo '[Unit]';
echo 'Description=Zeronet Server' >> $DAEMON_FILENAME echo 'Description=Zeronet Server';
echo 'After=syslog.target' >> $DAEMON_FILENAME echo 'After=syslog.target';
echo 'After=network.target' >> $DAEMON_FILENAME echo 'After=network.target';
echo '[Service]' >> $DAEMON_FILENAME echo '[Service]';
echo 'Type=simple' >> $DAEMON_FILENAME echo 'Type=simple';
echo 'User=zram' >> $DAEMON_FILENAME echo 'User=zram';
echo 'Group=zram' >> $DAEMON_FILENAME echo 'Group=zram';
echo 'WorkingDirectory=' >> $DAEMON_FILENAME echo 'WorkingDirectory=';
echo "ExecStart=${PROJECT_NAME}-zram on" >> $DAEMON_FILENAME echo "ExecStart=${PROJECT_NAME}-zram on";
echo '' >> $DAEMON_FILENAME echo '';
echo '[Install]' >> $DAEMON_FILENAME echo '[Install]';
echo 'WantedBy=multi-user.target' >> $DAEMON_FILENAME echo 'WantedBy=multi-user.target'; } >> $DAEMON_FILENAME
} }
function zram_on { function zram_on {
@ -76,17 +75,17 @@ function zram_on {
# initialize the devices # initialize the devices
for i in $(seq 0 $decr_num_cpus); do for i in $(seq 0 $decr_num_cpus); do
echo $((mem_total / num_cpus)) > /sys/block/zram$i/disksize echo $((mem_total / num_cpus)) > "/sys/block/zram$i/disksize"
done done
# Creating swap filesystems # Creating swap filesystems
for i in $(seq 0 $decr_num_cpus); do for i in $(seq 0 $decr_num_cpus); do
mkswap /dev/zram$i mkswap "/dev/zram$i"
done done
# Switch the swaps on # Switch the swaps on
for i in $(seq 0 $decr_num_cpus); do for i in $(seq 0 $decr_num_cpus); do
swapon -p 100 /dev/zram$i swapon -p 100 "/dev/zram$i"
done done
zram_daemon zram_daemon
@ -103,8 +102,8 @@ function zram_off {
# Switching off swap # Switching off swap
for i in $(seq 0 $decr_num_cpus); do for i in $(seq 0 $decr_num_cpus); do
if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then if [ "$(grep "/dev/zram$i" /proc/swaps)" != "" ]; then
swapoff /dev/zram$i swapoff "/dev/zram$i"
sleep 1 sleep 1
fi fi
done done
@ -123,7 +122,7 @@ function show_help {
exit 0 exit 0
} }
if [ ! $1 ]; then if [ ! "$1" ]; then
show_help show_help
else else
if [[ "$1" == "on" || "$1" == "enable" || "$1" == "yes" ]]; then if [[ "$1" == "on" || "$1" == "enable" || "$1" == "yes" ]]; then