Skip to content

Commit

Permalink
Initial attempt to add post init scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
mastacontrola committed Jan 11, 2017
1 parent d6b5319 commit 04c8755
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
12 changes: 10 additions & 2 deletions lib/common/functions.sh
Expand Up @@ -1063,14 +1063,22 @@ configureStorage() {
[[ ! -f $storageLocation/.mntcheck ]] && touch $storageLocation/.mntcheck >>$workingdir/error_logs/fog_error_${version}.log 2>&1
[[ ! -d $storageLocation/postdownloadscripts ]] && mkdir $storageLocation/postdownloadscripts >>$workingdir/error_logs/fog_error_${version}.log 2>&1
if [[ ! -f $storageLocation/postdownloadscripts/fog.postdownload ]]; then
echo "#!/bin/sh" >"$storageLocation/postdownloadscripts/fog.postdownload"
echo "#!/bin/bash" >"$storageLocation/postdownloadscripts/fog.postdownload"
echo "## This file serves as a starting point to call your custom postimaging scripts." >>"$storageLocation/postdownloadscripts/fog.postdownload"
echo "## <SCRIPTNAME> should be changed to the script you're planning to use." >>"$storageLocation/postdownloadscripts/fog.postdownload"
echo "## Syntax of post download scripts are" >>"$storageLocation/postdownloadscripts/fog.postdownload"
echo "#. \${postdownpath}<SCRIPTNAME>" > "$storageLocation/postdownloadscripts/fog.postdownload"
echo "#. \${postdownpath}<SCRIPTNAME>" >> "$storageLocation/postdownloadscripts/fog.postdownload"
fi
[[ ! -d $storageLocationCapture ]] && mkdir $storageLocationCapture >>$workingdir/error_logs/fog_error_${version}.log 2>&1
[[ ! -f $storageLocationCapture/.mntcheck ]] && touch $storageLocationCapture/.mntcheck >>$workingdir/error_logs/fog_error_${version}.log 2>&1
[[ ! -d $storageLocationCapture/postinitscripts ]] && mkdir $storageLocationCapture/postinitscripts >>$workingdir/error_logs/fog_error_${version}.log 2>&1
if [[ ! -f $storageLocationCapture/postinitscripts/fog.postinit ]]; then
echo "#!/bin/bash" >"$storageLocationCapture/postdownloadscripts/fog.postinit"
echo "## This file serves as a starting point to call your custom pre-imaging/post init loading scripts." >>"$storageLocationCapture/postinitscripts/fog.postinit"
echo "## <SCRIPTNAME> should be changed to the script you're planning to use." >>"$storageLocationCapture/postinitscripts/fog.postinit"
echo "## Syntax of post init scripts are" >>"$storageLocationCapture/postinitscripts/fog.postinit"
echo "#. \${postinitpath}<SCRIPTNAME>" >>"$storageLocationCapture/postinitscripts/fog.postinit"
fi
chmod 777 $storageLocation $storageLocationCapture >>$workingdir/error_logs/fog_error_${version}.log 2>&1
errorStat $?
}
Expand Down
24 changes: 19 additions & 5 deletions packages/web/lib/fog/bootmenu.class.php
Expand Up @@ -1385,6 +1385,25 @@ public function getTasking()
if (is_numeric($image_PIGZ) && $image_PIGZ > -1) {
$PIGZ_COMP = $image_PIGZ;
}
} else {
// These setup so postinit scripts can operate.
if ($StorageNode instanceof StorageNode
&& $StorageNode->isValid()
) {
$ip = trim($StorageNode->get('ip'));
$ftp = $ip;
} else {
$ip = $tftp;
$ftp = $tftp;
}
$storage = escapeshellcmd(
sprintf(
'%s:/%s/dev/',
$ip,
trim($StorageNode->get('path'), '/')
)
);
$storageip = $ip;
}
}
if ($this->_Host && $this->_Host->isValid()) {
Expand All @@ -1400,11 +1419,6 @@ public function getTasking()
'/opt/fog/clamav'
);
}
if ($StorageNode instanceof StorageNode && $StorageNode->isValid()) {
$ftp = $ip;
} else {
$ftp = $tftp;
}
$chkdsk = $chkdsk == 1 ? 0 : 1;
$MACs = $this->_Host->getMyMacs();
$clientMacs = array_filter(
Expand Down
2 changes: 1 addition & 1 deletion packages/web/lib/fog/system.class.php
Expand Up @@ -53,7 +53,7 @@ private static function _versionCompare()
public function __construct()
{
self::_versionCompare();
define('FOG_VERSION', '1.3.1-RC-6');
define('FOG_VERSION', '10');
define('FOG_SCHEMA', 245);
define('FOG_BCACHE_VER', 111);
define('FOG_SVN_REVISION', 6052);
Expand Down
2 changes: 1 addition & 1 deletion packages/web/management/languages/messages.pot
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-01-11 16:03-0500\n"
"POT-Creation-Date: 2017-01-11 18:54-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down
20 changes: 20 additions & 0 deletions src/buildroot/package/fog/scripts/bin/fog
Expand Up @@ -6,6 +6,26 @@ if [[ $boottype == usb && ! -z $web ]]; then
wget -q -O /tmp/hinfo.txt "http://${web}service/hostinfo.php?mac=$mac"
[[ -f /tmp/hinfo.txt ]] && . /tmp/hinfo.txt
fi
dots "Running post init scripts"
[[ ! -d /imagesinit ]] && mkdir /imagesinit >/dev/null 2>&1
umount /imagesinit >/dev/null 2>&1
mount -o nolock,proto=tcp,rsize=32768,wsize=32768,intr,noatime "$storage" /imagesinit >/tmp/mount-output 2>&1
if [[ $? -eq 0 ]]; then
if [[ -f /imagesinit/.mntcheck ]]; then
if [[ -f /imagesinit/postinitscripts/fog.postinit ]]; then
postinitpath="/imagesinit/postinitscripts/"
elif [[ -f /imagesinit/dev/postinitscripts/fog.postinit ]]; then
postinitpath="/imagesinit/dev/postinitscripts/"
fi
. ${postinitpath}fog.postinit
fi
umount /imagesinit >/dev/null 2>&1
echo "Done"
debugPause
else
echo "Skipped"
debugPause
fi
if [[ -n $mode && $mode != +(*debug*) && -z $type ]]; then
case $mode in
wipe)
Expand Down

0 comments on commit 04c8755

Please sign in to comment.