./init-host.sh ./init-development-env.sh
./init-development-env.sh
./clean-development-env.sh ./rebuild.sh
./rebuild.sh
./init-host.sh ./init-development-env.sh
./init-development-env.sh
./clean-development-env.sh ./rebuild.sh
./rebuild.sh
#/bin/bash | |
working_dir=${HOME}/local-share-juju | |
juju_config_dir=${HOME}/.local/share/juju | |
backup_dir=${working_dir}/local-share-juju-$(date +%y%m%d-%H%M%S) | |
# backup original juju config | |
# | |
# a clean juju credential config is critical in our deployment case until our | |
# charm smart enough | |
# | |
mkdir -p ${working_dir} | |
mv ${juju_config_dir} ${backup_dir} | |
# purge all lxd containers | |
container_names=$(lxc list -c n --format csv) | |
for container_name in ${container_names} | |
do | |
lxc stop ${container_name} | |
lxc delete ${container_name} | |
done |
#/bin/bash | |
source ./clean-development-env.sh | |
echo "wait for netplan re-rendering..." | |
sleep 15 | |
# rebuild by bootstraping | |
echo "juju bootstraping..." | |
juju bootstrap localhost | |
# deploy the target service, our local scalebot!! | |
pushd ${HOME}/local-sync/scalebot | |
juju deploy ./common_bundle.yaml --overlay ./labs/remote-lxd-dev/overlay_bundle.yaml | |
popd |
#/bin/bash | |
mkdir -p ${HOME}/local-share-juju | |
sudo apt remove --purge lxd lxd-client -y | |
sudo groupadd --system lxd | |
sudo usermod -G lxd -a $(whoami) | |
sudo snap install juju --classic | |
sudo snap install lxd | |
lxd init --preseed < lxd-init-scalebot.yaml | |
# have no idea where the password is stored | |
# dump to an yaml does not get the password as well | |
# maybe I could lxc copy the client cert? | |
lxc config set core.trust_password insecure | |
# (optional) to access the remote local scalebot jenkins via your browser | |
git clone https://github.com/tai271828/lxd-forward.git ${HOME}/ | |
could be a project or folder name |
config: | |
core.https_address: '[::]' | |
core.trust_password: true | |
networks: | |
- config: | |
ipv4.address: 10.94.220.1/24 | |
ipv4.nat: "true" | |
ipv6.address: none | |
ipv6.nat: "false" | |
description: "" | |
name: lxdbr0 | |
type: bridge | |
project: default | |
storage_pools: | |
- config: | |
source: /var/snap/lxd/common/lxd/storage-pools/default | |
description: "" | |
name: default | |
driver: dir | |
profiles: | |
- config: {} | |
description: Default LXD profile | |
devices: | |
eth0: | |
nictype: bridged | |
parent: lxdbr0 | |
type: nic | |
root: | |
path: / | |
pool: default | |
type: disk | |
name: default |
#!/bin/bash | |
#./clean-development-env.sh | |
juju destroy-model default --force -y | |
juju add-model default | |
./sync-src.sh | |
juju bootstrap localhost | |
pushd ${HOME}/local-sync/scalebot | |
juju deploy ./common_bundle.yaml --overlay ./labs/remote-lxd-dev/overlay_bundle.yaml | |
popd |
#!/bin/bash | |
# TODO: | |
# 1. customized username | |
# 2. support local build | |
scalebot_projects=${HOME}/work/scalebot-projects | |
scalebot_parent=${scalebot_projects} | |
scalebot_name=scalebot | |
scalebot_jenkins_parent=${scalebot_projects} | |
scalebot_jenkins_name=scalebot-jenkins | |
scalebot_jenkins_charm_parent=/tmp/charm-builds | |
scalebot_jenkins_charm_name=${scalebot_jenkins_name}-charm | |
scalebot_jenkins_charm=${scalebot_jenkins_charm_parent}/${scalebot_jenkins_charm_name} | |
tmp_tar_place=/tmp/sync-files | |
target_working_dir=/home/ubuntu/local-sync | |
target_username_ip=$1 | |
sshs='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' | |
scps='scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' | |
function remote_sync { | |
rm -rf ${tmp_tar_place} | |
mkdir -p ${tmp_tar_place} | |
tar -zcf ${tmp_tar_place}/${scalebot_name}.tar.gz -C ${scalebot_parent} ./${scalebot_name} | |
tar -zcf ${tmp_tar_place}/${scalebot_jenkins_charm_name}.tar.gz -C ${scalebot_jenkins_charm_parent} ./${scalebot_jenkins_charm_name} | |
echo "scp ing... make sure your VPN is enabled" | |
$sshs ${target_username_ip} rm -rf ${target_working_dir} | |
$sshs ${target_username_ip} mkdir -p ${target_working_dir} | |
$scps ${tmp_tar_place}/${scalebot_name}.tar.gz ${target_username_ip}:${target_working_dir}/ | |
$scps ${tmp_tar_place}/${scalebot_jenkins_charm_name}.tar.gz ${target_username_ip}:${target_working_dir}/ | |
$sshs ${target_username_ip} "cd ${target_working_dir}; tar -zxf ${target_working_dir}/${scalebot_name}.tar.gz" | |
$sshs ${target_username_ip} "cd ${target_working_dir}; tar -zxf ${target_working_dir}/${scalebot_jenkins_charm_name}.tar.gz" | |
} | |
rm -rf ${scalebot_jenkins_charm_parent}/${scalebot_jenkins_charm_name} | |
pushd ${scalebot_jenkins_parent}/${scalebot_jenkins_name} | |
charm build ./ -o ${scalebot_jenkins_charm} | |
popd | |
if [ -z "${target_username_ip}" -o "${target_username_ip}" == "local" ] | |
then | |
echo "Charm is built." | |
echo "done." | |
else | |
echo "Charm is built. Now sync up with the remote host ${target_username_ip}" | |
remote_sync | |
echo "done." | |
fi | |
integrate all scripts to be a Makefile |