Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
5 contributors

Users who have contributed to this file

@gavofyork @shawntabrizi @xlc @attente @joepetrowski
executable file 104 lines (85 sloc) 2.35 KB
#!/usr/bin/env bash
COLOR_WHITE=$(tput setaf 7);
COLOR_MAGENTA=$(tput setaf 5);
FONT_BOLD=$(tput bold);
FONT_NORMAL=$(tput sgr0);
echo
echo -e "$COLOR_WHITE $FONT_BOLD Substrate Node Template Setup $FONT_NORMAL";
name=$1
shift
author=$1
shift
if [[ "$name" == "" || "$name" == "-"* ]]
then
echo " Usage: substrate-node-new <NAME> <AUTHOR>"
echo
exit 1
fi
if [[ "$author" == "" || "$author" == "-"* ]]
then
echo " Usage: substrate-node-new <NAME> <AUTHOR>"
echo
exit 1
fi
lname="$(echo $name | tr '[:upper:]' '[:lower:]')"
dirname="${lname// /-}"
bold=$(tput bold)
normal=$(tput sgr0)
if [ -d "$dirname" ]; then
echo " Directory '$name' already exists!"
echo
exit 1
fi
echo "${bold} Downloading project...${normal}"
if ! curl http://releases.parity.io/substrate/x86_64-debian:stretch/latest-v1.0/substrate-node-template.tar.gz | tar xz
then
exit 1
fi
mv substrate-node-template $dirname
pushd $dirname >/dev/null
echo "${bold}Customizing project...${normal}"
function replace {
find_this="$1"
shift
replace_with="$1"
shift
IFS=$'\n'
TEMP=$(mktemp -d "${TMPDIR:-/tmp}/.XXXXXXXXXXXX")
rmdir $TEMP
for item in `find . -type f`
do
sed "s/$find_this/$replace_with/g" "$item" > $TEMP
cat $TEMP > "$item"
done
rm -f $TEMP
}
replace "Template Node" "${name}"
replace node-template "${lname//[_ ]/-}"
replace node_template "${lname//[- ]/_}"
replace Anonymous "$author"
echo "${bold}Initializing repository...${normal}"
git init 2>/dev/null >/dev/null
cat >.gitignore <<EOL
# Generated by Cargo
# will have compiled files and executables
**/target/
# These are backup files generated by rustfmt
**/*.rs.bk
EOL
git add * .gitignore 2>/dev/null >/dev/null
git commit -a -m "Initial clone from template node" 2>/dev/null >/dev/null
echo "${bold}Initializing WebAssembly build environment...${normal}"
./scripts/init.sh 2>/dev/null >/dev/null
./scripts/build.sh
echo "${bold}Building node...${normal}"
cargo build --release
echo
echo "${bold}Chain client created in ${dirname}${normal}."
echo "To start a dev chain, run:"
echo "$ $dirname/target/release/${lname//[_ ]/-} --dev"
echo "To create a basic Bonds UI for your chain, run:"
echo "$ substrate-ui-new $name"
echo "To push to a newly created GitHub repository, inside ${dirname}, run:"
echo "$ git remote add origin git@github.com:myusername/myprojectname && git push -u origin master"
echo
popd >/dev/null
You can’t perform that action at this time.