Skip to content

Instantly share code, notes, and snippets.

@jperkin
Created March 24, 2014 17:07
Show Gist options
  • Save jperkin/9744591 to your computer and use it in GitHub Desktop.
Save jperkin/9744591 to your computer and use it in GitHub Desktop.
lx_init_zone diff
--- /usr/lib/brand/lx/lx_init_zone Fri Mar 21 21:08:37 2014
+++ lx_init_zone Sun Mar 23 00:04:05 2014
@@ -440,31 +440,33 @@
# User must configure various brand-specific items to enable networking, so
# boot the system non-networked.
#
-log ""
-log "Modifying: \"$install_root/etc/sysconfig/network\"..."
+if [[ -d etc/sysconfig ]]; then
+ log ""
+ log "Modifying: \"$install_root/etc/sysconfig/network\"..."
-mv -f etc/sysconfig/network etc/sysconfig/network.$tag 2>/dev/null
+ mv -f etc/sysconfig/network etc/sysconfig/network.$tag 2>/dev/null
-cat > etc/sysconfig/network <<- EOF
- NETWORKING="no"
- #
- # To enable networking, change the "no" above to "yes" and
- # uncomment and fill in the following parameters.
- #
- # If you are specifying a hostname by name rather than by IP address,
- # be sure the system can resolve the name properly via the use of a
- # name service and/or the proper name files, as specified by
- # nsswitch.conf. See nsswitch.conf(5) for further details.
- #
- # HOSTNAME=your_hostname_here
- #
-EOF
+ cat > etc/sysconfig/network <<- EOF
+ NETWORKING="no"
+ #
+ # To enable networking, change the "no" above to "yes" and
+ # uncomment and fill in the following parameters.
+ #
+ # If you are specifying a hostname by name rather than by IP address,
+ # be sure the system can resolve the name properly via the use of a
+ # name service and/or the proper name files, as specified by
+ # nsswitch.conf. See nsswitch.conf(5) for further details.
+ #
+ # HOSTNAME=your_hostname_here
+ #
+ EOF
-if [[ $? -ne 0 ]]; then
- log "Could not create new \"$install_root/etc/sysconfig/network\"!"
- i18n_echo "$create_failed" "$install_root/etc/sysconfig/network"
- i18n_echo "$install_aborted"
- exit 1
+ if [[ $? -ne 0 ]]; then
+ log "Could not create new \"$install_root/etc/sysconfig/network\"!"
+ i18n_echo "$create_failed" "$install_root/etc/sysconfig/network"
+ i18n_echo "$install_aborted"
+ exit 1
+ fi
fi
if [[ -a etc/sysconfig/syslog ]]; then
@@ -592,23 +594,25 @@
#
# Don't bother to modify the file if it looks like we already did.
#
-if ! egrep -s "Disabled by lx brand" etc/rc.d/init.d/halt; then
- log ""
- log "Modifying \"$install_root/etc/rc.d/init.d/halt\" for operation"
- log " within a zone..."
- awk 'BEGIN {skip = ""}
- /^# Save mixer/ {skip = "# Disabled by lx brand: "}
- /halt.local/ {skip = ""}
- /./ {print skip $0}' etc/rc.d/init.d/halt > /tmp/halt.$$
+if [[ -f etc/rc.d/init.d/halt ]]; then
+ if ! egrep -s "Disabled by lx brand" etc/rc.d/init.d/halt; then
+ log ""
+ log "Modifying \"$install_root/etc/rc.d/init.d/halt\" for operation"
+ log " within a zone..."
+ awk 'BEGIN {skip = ""}
+ /^# Save mixer/ {skip = "# Disabled by lx brand: "}
+ /halt.local/ {skip = ""}
+ /./ {print skip $0}' etc/rc.d/init.d/halt > /tmp/halt.$$
- if [[ $? -eq 0 ]]; then
- mv -f etc/rc.d/init.d/halt etc/rc.d/init.d/halt.$tag 2>/dev/null
- mv -f /tmp/halt.$$ etc/rc.d/init.d/halt
- chmod 755 etc/rc.d/init.d/halt
- else
- log "Attempt to modify \"$install_root/etc/rc.d/init.d/halt\"" \
- "FAILED"
- log "Continuing with balance of zone setup..."
+ if [[ $? -eq 0 ]]; then
+ mv -f etc/rc.d/init.d/halt etc/rc.d/init.d/halt.$tag 2>/dev/null
+ mv -f /tmp/halt.$$ etc/rc.d/init.d/halt
+ chmod 755 etc/rc.d/init.d/halt
+ else
+ log "Attempt to modify \"$install_root/etc/rc.d/init.d/halt\"" \
+ "FAILED"
+ log "Continuing with balance of zone setup..."
+ fi
fi
fi
@@ -631,47 +635,49 @@
#
# Don't modify the rc.sysinit file if it looks like we already did.
#
-if ! egrep -s "Disabled by lx brand" etc/rc.d/rc.sysinit; then
- log ""
- log "Modifying: \"$install_root/etc/rc.d/rc.sysinit\"..."
- log ""
+if [[ -f etc/rc.d/rc.sysinit ]]; then
+ if ! egrep -s "Disabled by lx brand" etc/rc.d/rc.sysinit; then
+ log ""
+ log "Modifying: \"$install_root/etc/rc.d/rc.sysinit\"..."
+ log ""
- tmpfile=/tmp/lx_rc.sysinit.$$
+ tmpfile=/tmp/lx_rc.sysinit.$$
- sed 's@^/sbin/hwclock@# Disabled by lx brand: &@
- s@^HOSTTYPE=@HOSTTYPE=\"s390\" # Spoofed for lx brand: &@
- s@/bin/dmesg -n@: # Disabled by lx brand: &@
- s@^dmesg -s@# Disabled by lx brand: &@
- s@initlog -c \"fsck@: # Disabled by lx brand: &@
- s@^.*mount .* /dev/pts$@# Disabled by lx brand: &@' \
- etc/rc.d/rc.sysinit > $tmpfile
+ sed 's@^/sbin/hwclock@# Disabled by lx brand: &@
+ s@^HOSTTYPE=@HOSTTYPE=\"s390\" # Spoofed for lx brand: &@
+ s@/bin/dmesg -n@: # Disabled by lx brand: &@
+ s@^dmesg -s@# Disabled by lx brand: &@
+ s@initlog -c \"fsck@: # Disabled by lx brand: &@
+ s@^.*mount .* /dev/pts$@# Disabled by lx brand: &@' \
+ etc/rc.d/rc.sysinit > $tmpfile
- #
- # Only install the new rc.sysinit if the edit above succeeded.
- #
- if [[ $? -eq 0 ]]; then
#
- # Attempt to save off the original rc.sysinit
- # before moving over the modified version.
+ # Only install the new rc.sysinit if the edit above succeeded.
#
- mv -f etc/rc.d/rc.sysinit etc/rc.d/rc.sysinit.$tag 2>/dev/null
+ if [[ $? -eq 0 ]]; then
+ #
+ # Attempt to save off the original rc.sysinit
+ # before moving over the modified version.
+ #
+ mv -f etc/rc.d/rc.sysinit etc/rc.d/rc.sysinit.$tag 2>/dev/null
- if ! mv -f $tmpfile etc/rc.d/rc.sysinit; then
- log "mv of \"$tmpfile\" to" \
- "\"$installroot/etc/rc.d/rc.sysinit\" failed!"
- i18n_echo "$cmd2_failed" "mv" "$tmpfile" \
- "$installroot/etc/rc.d/rc.sysinit"
+ if ! mv -f $tmpfile etc/rc.d/rc.sysinit; then
+ log "mv of \"$tmpfile\" to" \
+ "\"$installroot/etc/rc.d/rc.sysinit\" failed!"
+ i18n_echo "$cmd2_failed" "mv" "$tmpfile" \
+ "$installroot/etc/rc.d/rc.sysinit"
+ i18n_echo "$install_aborted"
+ exit 1
+ else
+ chmod 755 etc/rc.d/rc.sysinit
+ fi
+ else
+ log "Attempt to modify entries in" \
+ "\"$install_root/rc.d/rc.sysinit\" failed!"
+ i18n_echo "$mod_failed" "$install_root/rc.d/rc.sysinit"
i18n_echo "$install_aborted"
exit 1
- else
- chmod 755 etc/rc.d/rc.sysinit
fi
- else
- log "Attempt to modify entries in" \
- "\"$install_root/rc.d/rc.sysinit\" failed!"
- i18n_echo "$mod_failed" "$install_root/rc.d/rc.sysinit"
- i18n_echo "$install_aborted"
- exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment