Skip to content

Instantly share code, notes, and snippets.

@stdevPavelmc
Created November 13, 2018 13:11
Show Gist options
  • Save stdevPavelmc/5c9c2938683aa86e085c79d9f21365e3 to your computer and use it in GitHub Desktop.
Save stdevPavelmc/5c9c2938683aa86e085c79d9f21365e3 to your computer and use it in GitHub Desktop.
Fix the issue #80 (https://github.com/skycoin/skywire/issues/80) in skycoin/skywire repo
#!/bin/bash
# ** Goal **
# Update the init script of the skywire services running on this pc to
# fix a bug (https://github.com/skycoin/skywire/issues/80)
#
# ** Why? **
# A few time ago the dev team changed the skywire code to make it more
# portable using dynamic paths (learning for the environment, that's
# the right way to doit) But the image was still configured in a static
# way and that break the nodes once you update the skywire code.
#
# ** What it does? **
# This script fix that by setting the pc environment at service init
# time to cope with that change; making the least invasive change to
# keeping the code as portable as possible.
#
# ** Note **
# This is a temporary fix, the re-build of the images with this fix
# built in must be the final fix.
#
# ** Author **
# stdevPavelmc@github.com from Simelo/skycoin team
# Date: nov 13 01:22:27 CST 2018
# local vars.
DEST="/etc/rebuild.sh"
SOURCE="/etc/bootsamos.sh"
# To check if the rebuild.sh script has the fix already.
FIXED=`cat $DEST | grep "export"`
# Magic goes here
if [ -z "$FIXED" ] ; then
# yes, it need to be fixed.
echo "Broken system, fixing that."
echo '#!/bin/bash' > $DEST
echo "export GOPATH=/usr/local/skywire/go" >> $DEST
echo "export GOROOT=/usr/local/go" >> $DEST
cat $SOURCE >> $DEST
echo "Done, please reboot your node to apply changes."
else
# already fixed, alert the user and exit
echo "Already fixed, nothing to do, bye."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment