Service file /etc/init.d/s3fsd
#!/bin/bash
start()
{
if [ ! -f /var/run/s3fs_lock ]
then
touch /var/run/s3fs_lock
./usr/bin/s3fs &
sleep 1
if [ -f "/var/run/s3fs_lock" ]
then
echo -e "\e[1;32m s3fs service \e[0;36m [started] \e[0m"
else
echo "Error in starting the service , Please check var log messages"
fi
else
echo -e "\e[1;32m s3fs service \e[1;35m [Already Running] \e[0m"
echo -e "\n Please do restart , if the service is not proper\n"
fi
}
stop()
{
if [ ! -f "/var/run/s3fs_lock" ]
then
echo -e "\e[1;32m s3fs service \e[1;35m [Already Stopped] \e[0m"
else
rm -rf /var/run/s3fs_lock
echo -e "\e[1;32m s3fs service \e[0;36m [stopped] \e[0m"
fi
}
status()
{
if [ -f "/var/run/s3fs_lock" ]
then
echo -e "\e[1;32m s3fs service \e[1;33m [Running] \e[0m"
else
echo -e "\e[1;32m s3fs service \e[1;35m [Not Running] \e[0m"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
## Running code file
#!/bin/bash
while true
do
[ ! -f "/var/run/s3fs_lock" ] && echo "service stopped" >> /tmp/logs && kill -9 $$
echo "`date`" >> /tmp/logs
cat /etc/s3fs.conf | grep -v '#' | grep -v '^$' > /tmp/s3fs_tmp
line="`wc -l /tmp/s3fs_tmp 2> /dev/null | awk '{print $1}'`"
if [ $line -lt 1 ]
then
logger "/etc/s3fs.conf file is empty , please make some entry and restart the service"
rm -rf /var/run/s3fs_lock
exit 0
fi
cat /etc/s3fs.conf | grep -v '#' | grep -v '^$' | while read i
do
source="`echo $i | awk '{print $1}'`"
destination="`echo $i | awk '{print $2}'`"
check="`df -h | grep -i $destination`"
if [ ! "$check" ]
then
mount $source $destination
fi
done
sleep 5
done
## Configuration File
cat /etc/s3fs.conf
#bucktname mountpoints options
/dev/sam/sam /sam
#!/bin/bash
start()
{
if [ ! -f /var/run/s3fs_lock ]
then
touch /var/run/s3fs_lock
./usr/bin/s3fs &
sleep 1
if [ -f "/var/run/s3fs_lock" ]
then
echo -e "\e[1;32m s3fs service \e[0;36m [started] \e[0m"
else
echo "Error in starting the service , Please check var log messages"
fi
else
echo -e "\e[1;32m s3fs service \e[1;35m [Already Running] \e[0m"
echo -e "\n Please do restart , if the service is not proper\n"
fi
}
stop()
{
if [ ! -f "/var/run/s3fs_lock" ]
then
echo -e "\e[1;32m s3fs service \e[1;35m [Already Stopped] \e[0m"
else
rm -rf /var/run/s3fs_lock
echo -e "\e[1;32m s3fs service \e[0;36m [stopped] \e[0m"
fi
}
status()
{
if [ -f "/var/run/s3fs_lock" ]
then
echo -e "\e[1;32m s3fs service \e[1;33m [Running] \e[0m"
else
echo -e "\e[1;32m s3fs service \e[1;35m [Not Running] \e[0m"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
## Running code file
#!/bin/bash
while true
do
[ ! -f "/var/run/s3fs_lock" ] && echo "service stopped" >> /tmp/logs && kill -9 $$
echo "`date`" >> /tmp/logs
cat /etc/s3fs.conf | grep -v '#' | grep -v '^$' > /tmp/s3fs_tmp
line="`wc -l /tmp/s3fs_tmp 2> /dev/null | awk '{print $1}'`"
if [ $line -lt 1 ]
then
logger "/etc/s3fs.conf file is empty , please make some entry and restart the service"
rm -rf /var/run/s3fs_lock
exit 0
fi
cat /etc/s3fs.conf | grep -v '#' | grep -v '^$' | while read i
do
source="`echo $i | awk '{print $1}'`"
destination="`echo $i | awk '{print $2}'`"
check="`df -h | grep -i $destination`"
if [ ! "$check" ]
then
mount $source $destination
fi
done
sleep 5
done
## Configuration File
cat /etc/s3fs.conf
#bucktname mountpoints options
/dev/sam/sam /sam
No comments:
Post a Comment