mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-22 07:30:24 +00:00
install.sh
This commit is contained in:
parent
1c53fa95d5
commit
f456b1ea30
1 changed files with 33 additions and 11 deletions
|
@ -33,6 +33,11 @@ export PATH
|
||||||
#
|
#
|
||||||
# $ sudo bash install.sh --apps "wordpress,gitlab"
|
# $ sudo bash install.sh --apps "wordpress,gitlab"
|
||||||
#
|
#
|
||||||
|
# --mirrors <https://docker.rainbond.cc,https://registry.inner.websoft9.cn>
|
||||||
|
# Use the --mirrors option to set docker image mirrors when can not pull image from docker-hub, for example:
|
||||||
|
#
|
||||||
|
# $ sudo bash install.sh --mirrors "https://docker.rainbond.cc,https://registry.inner.websoft9.cn"
|
||||||
|
#
|
||||||
# --devto
|
# --devto
|
||||||
# Use the --devto option to developer mode, devto is the developer code path, for example:
|
# Use the --devto option to developer mode, devto is the developer code path, for example:
|
||||||
#
|
#
|
||||||
|
@ -46,6 +51,7 @@ version="latest"
|
||||||
channel="release"
|
channel="release"
|
||||||
path="/data/websoft9/source"
|
path="/data/websoft9/source"
|
||||||
apps=""
|
apps=""
|
||||||
|
mirrors="https://docker.rainbond.cc,https://registry.inner.websoft9.cn"
|
||||||
|
|
||||||
# 获取参数值
|
# 获取参数值
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
@ -95,6 +101,15 @@ while [[ $# -gt 0 ]]; do
|
||||||
apps="$1"
|
apps="$1"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--mirrors)
|
||||||
|
shift
|
||||||
|
if [[ $1 == --* ]]; then
|
||||||
|
echo "Missing value for --mirrors"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mirrors="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--devto)
|
--devto)
|
||||||
shift
|
shift
|
||||||
if [[ $1 == --* ]]; then
|
if [[ $1 == --* ]]; then
|
||||||
|
@ -137,6 +152,7 @@ echo "--port: $port"
|
||||||
echo "--channel: $channel"
|
echo "--channel: $channel"
|
||||||
echo "--path: $path"
|
echo "--path: $path"
|
||||||
echo "--apps: $apps"
|
echo "--apps: $apps"
|
||||||
|
echo "--mirrors: $mirrors"
|
||||||
echo "--devto: $devto"
|
echo "--devto: $devto"
|
||||||
|
|
||||||
echo -e "\nYour OS: "
|
echo -e "\nYour OS: "
|
||||||
|
@ -151,6 +167,7 @@ export install_path=$path
|
||||||
export channel
|
export channel
|
||||||
export version
|
export version
|
||||||
export apps
|
export apps
|
||||||
|
export mirrors
|
||||||
export systemd_path="/opt/websoft9/systemd"
|
export systemd_path="/opt/websoft9/systemd"
|
||||||
export source_zip="websoft9-$version.zip"
|
export source_zip="websoft9-$version.zip"
|
||||||
export source_unzip="websoft9"
|
export source_unzip="websoft9"
|
||||||
|
@ -429,23 +446,25 @@ install_backends() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DOCKER_CONFIG_FILE="/etc/docker/daemon.json"
|
DOCKER_CONFIG_FILE="/etc/docker/daemon.json"
|
||||||
MIRROR_ADDRESS="https://registry.test2.websoft9.cn"
|
MIRROR_ADDRESS=$mirrors
|
||||||
sudo docker compose -f $composefile pull
|
timeout 10s sudo docker compose -f $composefile pull
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Docker Compose pull succeeded"
|
echo "Docker Compose pull succeeded"
|
||||||
else
|
else
|
||||||
|
echo "Can not pull images from docker hub, set mirrors..."
|
||||||
if [ ! -f "$DOCKER_CONFIG_FILE" ]; then
|
if [ ! -f "$DOCKER_CONFIG_FILE" ]; then
|
||||||
echo "{}" > "$DOCKER_CONFIG_FILE"
|
echo "{}" | sudo tee "$DOCKER_CONFIG_FILE" > /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v jq >/dev/null 2>&1; then
|
if command -v jq >/dev/null 2>&1; then
|
||||||
jq ".\"registry-mirrors\" = [\"$MIRROR_ADDRESS\"]" "$DOCKER_CONFIG_FILE" > "$DOCKER_CONFIG_FILE.tmp" && mv "$DOCKER_CONFIG_FILE.tmp" "$DOCKER_CONFIG_FILE"
|
MIRROR_ARRAY=$(echo $MIRROR_ADDRESS | sed 's/,/","/g' | sed 's/^/["/' | sed 's/$/"]/')
|
||||||
|
#jq --arg mirrors "$MIRROR_ARRAY" '.["registry-mirrors"] = ($mirrors | fromjson)' "$DOCKER_CONFIG_FILE" > "$DOCKER_CONFIG_FILE.tmp" && sudo mv "$DOCKER_CONFIG_FILE.tmp" "$DOCKER_CONFIG_FILE"
|
||||||
|
jq ".\"registry-mirrors\" = $MIRROR_ARRAY" "$DOCKER_CONFIG_FILE" > "$DOCKER_CONFIG_FILE.tmp" && sudo mv "$DOCKER_CONFIG_FILE.tmp" "$DOCKER_CONFIG_FILE"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "jq not installed!"
|
echo "jq not installed!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl restart docker
|
sudo systemctl restart docker
|
||||||
fi
|
fi
|
||||||
|
@ -455,14 +474,17 @@ install_backends() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if jq -e 'has("registry-mirrors")' "$DOCKER_CONFIG_FILE" > /dev/null; then
|
if jq -e '.["registry-mirrors"]' "$DOCKER_CONFIG_FILE" > /dev/null; then
|
||||||
jq 'del(.["registry-mirrors"])' "$DOCKER_CONFIG_FILE" > "${DOCKER_CONFIG_FILE}.tmp" && mv "${DOCKER_CONFIG_FILE}.tmp" "$DOCKER_CONFIG_FILE"
|
jq 'del(.["registry-mirrors"])' "$DOCKER_CONFIG_FILE" > "${DOCKER_CONFIG_FILE}.tmp" && sudo mv "${DOCKER_CONFIG_FILE}.tmp" "$DOCKER_CONFIG_FILE"
|
||||||
systemctl restart docker
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl restart docker
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$execute_mode" = "install" ]; then
|
if [ "$execute_mode" = "install" ]; then
|
||||||
sudo docker exec -i websoft9-apphub apphub setconfig --section domain --key wildcard_domain --value ""
|
sudo docker exec -i websoft9-apphub apphub setconfig --section domain --key wildcard_domain --value ""
|
||||||
sudo docker exec -i websoft9-apphub apphub setconfig --section initial_apps --key keys --value $apps
|
if [ -n "$apps" ]; then
|
||||||
|
sudo docker exec -i websoft9-apphub apphub setconfig --section initial_apps --key keys --value "$apps"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,4 +561,4 @@ endtime=$(date +%s)
|
||||||
runtime=$((endtime-starttime))
|
runtime=$((endtime-starttime))
|
||||||
echo "Script execution time: $runtime seconds"
|
echo "Script execution time: $runtime seconds"
|
||||||
echo -e "\n-- Install success! ------"
|
echo -e "\n-- Install success! ------"
|
||||||
echo "Access Websoft9 console by: http://Internet IP:$(grep ListenStream /lib/systemd/system/cockpit.socket | cut -d= -f2) and using Linux user for login"
|
echo "Access Websoft9 console by: http://Internet IP:$(grep ListenStream /lib/systemd/system/cockpit.socket | cut -d= -f2) and using Linux user for login"
|
Loading…
Reference in a new issue