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
# 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'
fi
@ -81,24 +81,24 @@ ENABLE_SOCIAL_KEY_MANAGEMENT="no"
SOCIALINSTANCE=
# 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
do
source $f
source "$f"
done
# 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
do
source $f
source "$f"
done
#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
do
source $f
source "$f"
done
# 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
function zram_daemon {
echo '[Unit]' > $DAEMON_FILENAME
echo 'Description=Zeronet Server' >> $DAEMON_FILENAME
echo 'After=syslog.target' >> $DAEMON_FILENAME
echo 'After=network.target' >> $DAEMON_FILENAME
echo '[Service]' >> $DAEMON_FILENAME
echo 'Type=simple' >> $DAEMON_FILENAME
echo 'User=zram' >> $DAEMON_FILENAME
echo 'Group=zram' >> $DAEMON_FILENAME
echo 'WorkingDirectory=' >> $DAEMON_FILENAME
echo "ExecStart=${PROJECT_NAME}-zram on" >> $DAEMON_FILENAME
echo '' >> $DAEMON_FILENAME
echo '[Install]' >> $DAEMON_FILENAME
echo 'WantedBy=multi-user.target' >> $DAEMON_FILENAME
{ echo '[Unit]';
echo 'Description=Zeronet Server';
echo 'After=syslog.target';
echo 'After=network.target';
echo '[Service]';
echo 'Type=simple';
echo 'User=zram';
echo 'Group=zram';
echo 'WorkingDirectory=';
echo "ExecStart=${PROJECT_NAME}-zram on";
echo '';
echo '[Install]';
echo 'WantedBy=multi-user.target'; } >> $DAEMON_FILENAME
}
function zram_on {
@ -76,17 +75,17 @@ function zram_on {
# initialize the devices
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
# Creating swap filesystems
for i in $(seq 0 $decr_num_cpus); do
mkswap /dev/zram$i
mkswap "/dev/zram$i"
done
# Switch the swaps on
for i in $(seq 0 $decr_num_cpus); do
swapon -p 100 /dev/zram$i
swapon -p 100 "/dev/zram$i"
done
zram_daemon
@ -103,8 +102,8 @@ function zram_off {
# Switching off swap
for i in $(seq 0 $decr_num_cpus); do
if [ "$(grep /dev/zram$i /proc/swaps)" != "" ]; then
swapoff /dev/zram$i
if [ "$(grep "/dev/zram$i" /proc/swaps)" != "" ]; then
swapoff "/dev/zram$i"
sleep 1
fi
done
@ -123,7 +122,7 @@ function show_help {
exit 0
}
if [ ! $1 ]; then
if [ ! "$1" ]; then
show_help
else
if [[ "$1" == "on" || "$1" == "enable" || "$1" == "yes" ]]; then