Update start.sh
This commit is contained in:
parent
b786909b4f
commit
a340c65a22
22
start.sh
22
start.sh
@ -1,18 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
docker_path="/data/aix-docker"
|
docker_path="/data/aix-docker"
|
||||||
pushd /data
|
cd /data
|
||||||
function print_error() {
|
print_error() {
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
echo -e "${RED}[ERROR] $1${NC}" >&2
|
echo -e "${RED}[ERROR] $1${NC}" >&2
|
||||||
}
|
}
|
||||||
function print_success() {
|
print_success() {
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
echo -e "${GREEN}[SUCCESS] $1${NC}" >&2
|
echo -e "${GREEN}[SUCCESS] $1${NC}" >&2
|
||||||
}
|
}
|
||||||
if [ "$EUID" -ne 0 ]; then
|
query_euid=$(id -u)
|
||||||
|
if [ $query_euid -ne 0 ]; then
|
||||||
print_error "Please running as root"
|
print_error "Please running as root"
|
||||||
fi
|
fi
|
||||||
if [ -e "/root/.aix_docker.lock" ]; then
|
if [ -e "/root/.aix_docker.lock" ]; then
|
||||||
@ -27,6 +27,7 @@ if ! command -v jq >/dev/null 2>&1 ; then
|
|||||||
else
|
else
|
||||||
print_error "Unsupported Linux distribution"
|
print_error "Unsupported Linux distribution"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if ! command -v docker >/dev/null 2>&1 ; then
|
if ! command -v docker >/dev/null 2>&1 ; then
|
||||||
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-20.10.9.tgz
|
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/static/stable/x86_64/docker-20.10.9.tgz
|
||||||
@ -82,13 +83,14 @@ if [ ! -d "$docker_path" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
pushd /data/aix-docker
|
cd /data/aix-docker
|
||||||
|
|
||||||
yaml_file=$(find "$(pwd)" -type f -name "*.yaml" -o -name "*.yml" | head -n 1)
|
yaml_file=$(find "$(pwd)" -type f -name "*.yaml" -o -name "*.yml" | head -n 1)
|
||||||
if [ -n "$yaml_file" ]; then
|
if [ -n "$yaml_file" ]; then
|
||||||
if [ -z "$AIX_DOCKER_COMPOSER_FILE" ]; then
|
if [ -z "$AIX_DOCKER_COMPOSER_FILE" ]; then
|
||||||
echo 'export AIX_DOCKER_COMPOSER_FILE=$yaml_file' >> ~/.bashrc
|
echo -e "export AIX_DOCKER_COMPOSER_FILE=${yaml_file}" >> ~/.bashrc
|
||||||
source ~/.bashrc
|
export AIX_DOCKER_COMPOSER_FILE=$yaml_file
|
||||||
|
source /root/.bashrc
|
||||||
print_success "AIX_DOCKER_COMPOSER_FILE environment variable set to '$yaml_file'"
|
print_success "AIX_DOCKER_COMPOSER_FILE environment variable set to '$yaml_file'"
|
||||||
else
|
else
|
||||||
echo "AIX_DOCKER_COMPOSER_FILE is already set to: $AIX_DOCKER_COMPOSER_FILE"
|
echo "AIX_DOCKER_COMPOSER_FILE is already set to: $AIX_DOCKER_COMPOSER_FILE"
|
||||||
@ -101,7 +103,7 @@ if grep -q "/data/aix-docker/.alias" ~/.bashrc; then
|
|||||||
print_success ".alias is already sourced in ~/.bashrc"
|
print_success ".alias is already sourced in ~/.bashrc"
|
||||||
else
|
else
|
||||||
echo "source /data/aix-docker/.alias" >> ~/.bashrc
|
echo "source /data/aix-docker/.alias" >> ~/.bashrc
|
||||||
source ~/.bashrc
|
source /root/.bashrc
|
||||||
fi
|
fi
|
||||||
touch /root/.aix_docker.lock
|
touch /root/.aix_docker.lock
|
||||||
print_success "script init success!"
|
print_success "script init success!"
|
||||||
Loading…
x
Reference in New Issue
Block a user