#! /bin/sh ice_sh="bin/ice.sh" ice_bin="bin/ice.bin" ice_mod="${PWD##**/}" init_shy="etc/init.shy" local_shy="etc/local.shy" exit_shy="etc/exit.shy" main_go="src/main.go" readme="README.md" prepare() { [ -f ${readme} ] || cat >> ${readme} <> ${main_go} <> Makefile <> ${init_shy} <> ${local_shy} <> "${exit_shy}" <> ${ice_sh} <\$ctx_log && echo -e "\n\nrestarting..." || break done } restart() { [ -e \$ctx_pid ] && kill -2 \`cat \$ctx_pid\` || echo } shutdown() { [ -e \$ctx_pid ] && kill -3 \`cat \$ctx_pid\` || echo } serve() { prepare && shutdown && start \$@ } cmd=\$1 && [ -n "\$cmd" ] && shift || cmd=serve \$cmd \$* END chmod u+x ${ice_sh} } build() { export CGO_ENABLED=0 export GOPRIVATE=github.com export GOPROXY=https://goproxy.cn miss=./ && [ "$1" != "" ] && miss=$1 && shift && mkdir $miss cd $miss && prepare && go build -o ${ice_bin} ${main_go} && chmod u+x ${ice_bin} && ./${ice_sh} start serve } tutor() { [ -d $1 ] || mkdir $1 [ -f "$1/$1.js" ] || cat >> "$1/$1.js" <> "$1/$1.shy" <> "$1/$1.go" <