Skip to content

Instantly share code, notes, and snippets.

@yurafuca
Last active October 22, 2020 04:42
Show Gist options
  • Save yurafuca/80fef0e985660442bc16b3c50d2c34c7 to your computer and use it in GitHub Desktop.
Save yurafuca/80fef0e985660442bc16b3c50d2c34c7 to your computer and use it in GitHub Desktop.
trap "echo exit.; exit 1" 1 2 3 15
# snp のリポジトリのパス
snp="/mnt/c/Users/dt4841/dev/snp"
# gradle install するバンドルのパス
bundles=(
"apc/snp.com.library"
"apc/snp.gw.runtime"
"ctl/snp.gw.devif.lcos.if1"
"ctl/snp.gw.cmdadmin.if1"
"ctl/snp.gw.errstore.if1"
"ctl/snp.gw.lib.lba.if1"
"ctl/snp.gw.lib.jizai.if1"
"ctl/snp.gw.lib.pwrm.if1"
"ctl/snp.gw.lib.python.if1"
"ctl/snp.gw.lib.laser.if1"
"ctl/snp.gw.lib.iou.if1"
)
echo "======================================="
echo "Install expect"
echo "======================================="
# scp を自動化するのに必要
sudo apt install expect
echo "======================================="
echo "Start install"
echo "======================================="
cd $snp
for bundle in ${bundles[@]}; do
cd $snp
cd $bundle
# build.gradle からバージョンを読む
version=`grep -E "version ?= ?" "build.gradle" | sed "s/version//" | sed "s/[ ='\r\n]//g"`
echo -e "\e[1;37m📚${bundle} v${version}\e[m"
# Install
chmod +x gradlew
./gradlew install
echo ""
done
echo "======================================="
echo "Start build"
echo "======================================="
cd "$snp/ctl"
# Install all bundles.
for path in *; do
cd "$snp/ctl"
if [ ! -d $path ]; then
continue
fi
cd $path
if [ ! -e gradlew ]; then
continue
fi
# build.gradle からバージョンを読む
version=`grep -E "version ?= ?" "build.gradle" | sed "s/version//" | sed "s/[ ='\r\n]//g"`
echo -e "\e[1;37m🧱${path} v${version}\e[m"
# Build
chmod +x gradlew
./gradlew build
# Rename
jar="build/libs/${path}-${version}.jar"
jar_nover="build/libs/${path}.jar"
mv $jar $jar_nover
echo ""
done
echo "======================================="
echo "Start upload"
echo "======================================="
cd "$snp/ctl"
for path in *; do
cd "$snp/ctl"
if [ ! -d $path ]; then
continue
fi
cd $path
if [ ! -e gradlew ]; then
continue
fi
# build.gradle からバージョンを読む
version=`grep -E "version ?= ?" "build.gradle" | sed "s/version//" | sed "s/[ ='\r\n]//g"`
echo -e "\e[1;37m🚀${path} v${version}\e[m"
# Upload
jar="build/libs/${path}.jar"
expect -c "spawn scp $jar [email protected]:/usr/local/snp/fw/bundles ; expect password: ; send dev\r ; expect $ ; exit"
echo ""
done
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment