#!/bin/bash
by yi@tinoq.com
tmpfs_dir="/srv/tmpfs"
tmpfs_size=“5G”
tmpfs_user=“tinoq”
if [ $(id -u) != “0” ];then
echo “Error: You must be root to run this script”
exit 1
fi
if [ ! -d “${tmpfs_dir}” ];then
mkdir -p ${tmpfs_dir}
chown -R
t
m
p
f
s
u
s
e
r
.
{tmpfs_user}.
tmpfsuser.{tmpfs_user} ${tmpfs_dir}
fi
mount -t tmpfs -o size=${tmpfs_size} tmpfs ${tmpfs_dir}
if [
?
−
n
e
0
]
;
t
h
e
n
e
c
h
o
"
? -ne 0 ];then echo "
?−ne0];thenecho"(date +%F\ %T) mount tmpfs is failed" >> /var/log/tmpfs.log
else
echo “$(date +%F\ %T) mount tmpfs is ok” >> /var/log/tmpfs.log
fi