Skip to content

Instantly share code, notes, and snippets.

View liusheng's full-sized avatar

Liu sheng liusheng

  • China Xi'an
View GitHub Profile
@liusheng
liusheng / packer-testing.sh
Last active November 24, 2018 09:26
PoC of testing packer against huaweicloud
#######################################################
# Need to ensure following net, subnet, vpc, security group and testing image existed
# openstack network create packer-poc-net
# openstack subnet create --network packer-poc-net --subnet-range 10.0.20.0/24 packer-poc-subnet
# openstack router create packer-poc-vpc
# openstack router add subnet packer-poc-vpc packer-poc-subnet
# openstack security group create packer-poc-sg
# openstack security group rule create --ingress --protocol tcp --dst-port 22 packer-poc-sg
#
@liusheng
liusheng / query_latest_tag_by_repo.sh
Created November 28, 2018 08:40
query the latest released version tag of a repo
#!/bin/bash
#way 1:
curl --silent "https://api.github.com/repos/docker/machine/releases/latest" | python -c "import sys, json; print json.load(sys.stdin)['tag_name']"
# way 2:
apt install jq -y
curl --silent "https://api.github.com/repos/docker/machine/releases/latest" | jq -r .tag_name
@liusheng
liusheng / prepare_net_subnet_vpc.sh
Created November 28, 2018 09:10
prepare net, subnet, vpc for oepnlab jobs running
#!/bin/bash
_NET_PREFIX="openlab-jobs"
export OS_NETWORK_NAME="$_NET_PREFIX-net"
export OS_NETWORK_ID="$(openstack network show $OS_NETWORK_NAME -f value -c id)"
if [ -z "$OS_NETWORK_ID" ]; then
export OS_NETWORK_ID="$(openstack network create $OS_NETWORK_NAME -f value -c id)"
openstack subnet create --network $OS_NETWORK_ID --subnet-range 172.16.10.0/24 $_NET_PREFIX-subnet
fi
@liusheng
liusheng / config-golang-env.sh
Last active December 18, 2018 02:22
Config golangenv
#!/bin/bash
wget -c https://storage.googleapis.com/golang/go1.11.1.linux-amd64.tar.gz
sudo tar -C /usr/local/ -xvzf go1.11.1.linux-amd64.tar.gz
rm go1.11.1.linux-amd64.tar.gz
cat << EOF >> /etc/profile
export GOPATH=/home/zuul/
export PATH=/usr/local/go/bin:$GOPATH/bin:$PATH:
export GOBIN=$GOPATH/bin
EOF
@liusheng
liusheng / upload-cirros-image.sh
Created November 30, 2018 01:13
upload cirros image
#!/bin/bash
export OS_IMAGE_NAME="cirros-0.4.0-x86_64-disk"
export OS_IMAGE_ID="$(openstack image show $OS_IMAGE_NAME -f value -c id)"
if [ -z "$OS_IMAGE_ID" ]; then
curl -O http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
export OS_IMAGE_ID="$(openstack image create --file ./cirros-0.4.0-x86_64-disk.img --min-disk 1 --container-format bare --disk-format raw cirros-0.4.0-x86_64-disk -f value -c id)"
rm cirros-0.4.0-x86_64-disk.img
fi
@liusheng
liusheng / config-route-openshift-origin
Last active December 25, 2018 07:06
Config routing for openshift origin
1. configure `router-id` in `/etc/origin/cloudprovider/openstack.conf`
cat << EOF >> /etc/origin/cloudprovider/openstack.conf
[Route]
router-id = <router-id>
EOF
2. Adding following config options under `controllerArguments:` of `/etc/origin/master/master-config.yaml`
```
allocate-node-cidrs:
@liusheng
liusheng / example-checkout-github-pr.sh
Created December 25, 2018 08:13
example for checkout github pr
git remote add upstream https://github.com/docker/machine
git config --global user.email 'zuul@openlab.com'
git config --global user.name 'openlab'
git fetch upstream refs/pull/4545/head:pr4545
git cherry-pick pr4545
@liusheng
liusheng / deploy-openshift-origin-fusioncloud.sh
Last active June 4, 2019 09:11
How to deployment openshift origin on fusioncloud
# step1:在跳板机(执行ansible工具的机器上)clone openshift的ansible部署工具,并应用fusioncloud 规避patch:
git clone http://github.com/huaweicloud/openshift-ansible
cd openshift-ansible
git config --global user.email 'zuul@openlab.com'
git config --global user.name 'openlab'
git fetch origin refs/pull/12/head:pr12
git cherry-pick pr12
@liusheng
liusheng / sed_notes.sh
Created January 28, 2019 02:53
sed commands notes
# replace specific word with another word following rows of another specific word
sed -i '/OS::Neutron::Router/,+5s|aaa|bbb|' path/to/file
#similar
sed -i '/OS::Neutron::Router/,+5d' path/to/file
sed '/OS::Neutron::Router/,+5p' path/to/file
@liusheng
liusheng / Dockerfile
Last active July 22, 2022 23:58
Fix Hadoop Installation aarch64
FROM ubuntu:bionic
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
######
# Install common dependencies from packages. Versions here are either
# sufficient or irrelevant.
#
# WARNING: DO NOT PUT JAVA APPS HERE! Otherwise they will install default
# Ubuntu Java. See Java section below!