Last active
December 16, 2015 07:39
-
-
Save arnobroekhof/5400051 to your computer and use it in GitHub Desktop.
Converts the fstab of a linux to a puppet config file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
FILE=$1 | |
if [ -z $1 ] | |
then | |
echo "No file given" | |
exit 1 | |
fi | |
if [ ! -f $1 ] | |
then | |
echo "File $1 doesn't exist, exiting...." | |
exit 1 | |
fi | |
echo "# mount points from fstab" > "fstab.pp" | |
cat $1 |grep ^[^#$] | while read LINE; do | |
REMOTE=`echo $LINE | awk '{ print $1 }'` | |
LOCAL=`echo $LINE | awk '{ print $2 }'` | |
FSTYPE=`echo $LINE | awk '{ print $3 }'` | |
OPTS=`echo $LINE | awk '{ print $4 }'` | |
EXTRA=`echo $LINE | awk '{ print $5 " " $6 }'` | |
cat >> "fstab.pp" << EOF | |
# mount point ${REMOTE} | |
exec { "create-${LOCAL}-dir": | |
cwd => "/tmp", | |
creates => "${LOCAL}", | |
path => ["/usr/bin", "/usr/sbin","/bin"], | |
command => "/bin/mkdir -p ${LOCAL}", | |
} | |
mount { "${LOCAL}": | |
device => "${REMOTE}", | |
fstype => "${FSTYPE}", | |
ensure => "mounted", | |
options => "${OPTS}", | |
atboot => true, | |
require => Exec["create-${LOCAL}-dir"], | |
} | |
EOF | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment