ubuntu安装showdoc

安装showdoc

1. 自动脚本安装

下载脚本并赋予权限

wget https://www.showdoc.com.cn/script/showdoc;chmod +x showdoc;

默认安装中文版。如果想安装英文版,请加上en参数,如 ./showdoc en

自动安装

./showdoc

2. 安装依赖Docker Engine

2.1 卸载旧版本

sudo apt-get remove docker docker-engine docker.io containerd runc

2.2 安装方法

设置存储库

更新apt软件包索引并安装软件包以允许apt通过HTTPS使用存储库:

$ sudo apt-get update
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
添加Docker的官方GPG密钥:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88

pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]
安装
使用以下命令来设置稳定的存储库。要添加nightly或test存储库,请在下面的命令中在单词后面添加nightly或test(或两者)stable。
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
安装DOCKER引擎
更新apt程序包索引,并安装最新版本的Docker Engine和容器,或转到下一步以安装特定版本:
    $ sudo apt-get update
    $ sudo apt-get install docker-ce docker-ce-cli containerd.io
  

2.3 卸载Docker Engine

卸载Docker Engine,CLI和Containerd软件包:

$ sudo apt-get purge docker-ce docker-ce-cli containerd.io

主机上的镜像,容器,卷或自定义配置文件不会自动删除。要删除所有图像,容器和卷:

$ sudo rm -rf /var/lib/docker

showdoc自动下载安装脚本源码

#!/bin/bash
SHOWDOC_SCRIPT_VERSION='2.0'
if [[  -n "$1" ]] ; then 
	action=$1
else
	action='install'
fi
if [ "$action" == "start" ] ;then
	sudo -s  service docker start
	sudo -s docker start showdoc
	exit 1 
fi
if [ "$action" == "restart" ] ;then
	sudo -s docker restart showdoc 
	exit 1
fi
if [ "$action" == "stop" ] ;then
	sudo -s docker stop showdoc 
	exit 1
fi
if [ "$action" == "update" ] ;then
	DATE=$(date +%Y%m%d_%H%M%S_%N) 
	if [ ! -d "/showdoc_data/html" ]; then 
		echo  "Directory /showdoc_data/html does not exist"
		echo "/showdoc_data/html 目录不存在"
		exit 1 ;
	fi
	# 判断语言
	result=$(tail -n 1000 /showdoc_data/html/web/index.html | grep zh)
	if [ ! -z "$result" ] ; then 
		sudo -s docker pull registry.cn-shenzhen.aliyuncs.com/star7th/showdoc
		sudo -s docker tag registry.cn-shenzhen.aliyuncs.com/star7th/showdoc:latest star7th/showdoc:latest  
	else
		sudo -s docker pull star7th/showdoc
	fi

	sudo -s mv /showdoc_data/html /showdoc_data/html_bak_${DATE}

	sudo -s mkdir -p /showdoc_data/html
	sudo -s chmod  -R 777 /showdoc_data/html
	sudo -s docker stop showdoc && sudo -s docker rm showdoc 
	sudo -s docker run -d --name showdoc --env SHOWDOC_SCRIPT_VERSION=${SHOWDOC_SCRIPT_VERSION}  --user=root --privileged=true -p 4999:80 -v /showdoc_data/html:/var/www/html/ star7th/showdoc

	seconds_left=10
	while [ $seconds_left -gt 0 ];do
  		echo -n $seconds_left
  		sleep 1
  		seconds_left=$(($seconds_left - 1))
  		echo -ne "\r     \r" #清除本行文字
	done


	result=$(tail -n 1000 /showdoc_data/html_bak_${DATE}/web/index.html | grep zh)
	if [ ! -z "$result" ] ; then 
		curl http://localhost:4999/install/non_interactive.php?lang=zh
	else
		curl http://localhost:4999/install/non_interactive.php?lang=en
	fi

	\cp  -f  /showdoc_data/html_bak_${DATE}/Sqlite/showdoc.db.php /showdoc_data/html/Sqlite/showdoc.db.php
	\cp -r -f /showdoc_data/html_bak_${DATE}/Public/Uploads /showdoc_data/html/Public/
	sudo -s curl http://localhost:4999?s=/home/update/db

	sudo -s curl https://www.showdoc.com.cn/script/showdoc > ./showdoc

	exit 1
fi
if [ "$action" == "uninstall" ] ;then
	echo -e " Showdoc is about to be uninstalled. Are you sure to delete all showdoc data? [Y/n] \n 即将卸载showdoc,你是否确认删除showdoc所有数据? [Y/n]  "
	read -r -p '' input
	case $input in
	    [yY][eE][sS]|[yY])
				sudo -s docker stop showdoc
				sudo -s docker rm showdoc
				echo "uninstalling..."
				echo "正在卸载..."
				# 删除所有含有showdoc关键字的镜像
				sudo -s docker rmi  -f `docker images | grep showdoc| awk '{print $3}'` >/dev/null 2>&1
				# 删除数据目录
				sudo -s rm -rf /showdoc_data
				echo "Done"
				echo "完成"

			;;

	    [nN][oO]|[nN])
	       		;;
	    *)
		exit 1
		;;
	esac
	exit 1
fi
if ! [ -x "$(command -v docker)" ]; then
  echo 'It was detected that Docker was not installed. Attempting to install from the network... The time required is related to your network environment.'
  echo '检测到Docker尚未安装。正在试图从网络安装...所需时间与你的网络环境有关'
  sudo -s curl -sSL https://get.daocloud.io/docker | sh
  sudo -s  chkconfig docker on 
fi
if ! [ -x "$(command -v docker)" ]; then
  echo 'It was detected that Docker was not installed. Attempting to install from the network... The time required is related to your network environment.' 
  echo '检测到Docker尚未安装。正在试图从网络安装...所需时间与你的网络环境有关'
  sudo -s curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -
  sudo -s  chkconfig docker on 
fi
if ! [ -x "$(command -v docker)" ]; then
  echo 'Docker failed to install automatically. It is recommended that you install the docker environment manually before starting this script.' 
  echo 'Docker自动安装失败,建议你手动安装好docker环境后再启动本脚本' 
  exit 1 
fi

if  [  "$(docker images  |grep showdoc)" ]; then
  echo ""
  echo "You have installed showdoc image"
  echo "If you want to update showdoc, please execute  ./showdoc update "
  echo "If you want to restart showdoc, please execute    ./showdoc restart "
  echo "If you want to uninstall showdoc, please execute    ./showdoc uninstall "
  echo ""
  echo "你已经安装过showdoc镜像"
  echo "如果你想更新showdoc,请执行  ./showdoc update "
  echo "如果你想重启showdoc,请执行  ./showdoc restart "
  echo "如果你想卸载showdoc,请执行  ./showdoc uninstall "
  exit 1 
fi
sudo -s  service docker start
echo 'The showdoc image is being retrieved, please wait a moment... The time required is related to your network environment.'
echo '正在拉取showdoc镜像,请稍后...所需时间与你的网络环境有关'

if [ "$action" == "en" ] ;then
 	sudo -s docker pull star7th/showdoc
else
	sudo -s docker pull registry.cn-shenzhen.aliyuncs.com/star7th/showdoc
	sudo -s docker tag registry.cn-shenzhen.aliyuncs.com/star7th/showdoc:latest star7th/showdoc:latest 
fi



sudo -s mkdir /showdoc_data
if  [ ! -d "/showdoc_data" ]; then 
	echo "/showdoc_data directory does not exist. Make sure you have create permissions"
	echo "/showdoc_data 目录不存在,请确保有创建权限"
	exit 1 ;
fi
sudo -s mkdir /showdoc_data/html
sudo -s chmod  -R 777 /showdoc_data
sudo -s docker run -d --name showdoc --env SHOWDOC_SCRIPT_VERSION=${SHOWDOC_SCRIPT_VERSION}   --user=root --privileged=true -p 4999:80 -v /showdoc_data/html:/var/www/html/ star7th/showdoc

seconds_left=15
while [ $seconds_left -gt 0 ];do
  echo -n $seconds_left
  sleep 1
  seconds_left=$(($seconds_left - 1))
  echo -ne "\r     \r" #清除本行文字
done

if [ "$action" == "en" ] ;then
 	sudo -s curl http://localhost:4999/install/non_interactive.php?lang=en
else
	sudo -s curl http://localhost:4999/install/non_interactive.php?lang=zh
fi
sudo -s wget http://localhost:4999/install/install.lock
if [  -f "install.lock" ]; then 
	rm -rf install.lock 
	if [ "$action" == "en" ] ;then
		echo -e "\n \033[32m Successful installation , The address is:http://localhost:4999 (You can also use LAN or public IP / domain name access)  \033[0m \n"
		echo -e " \033[32m The account password is showdoc/123456 , After you log in, you can see the admin buttun at the top right.Suggested password modification after login   \033[0m \n"
		echo -e " \033[32m For questions or suggestions on showdoc, please go to  https://github.com/star7th/showdoc   \033[0m \n"

	else
		echo -e "\n \033[32m 安装成功,访问地址:http://localhost:4999 (你也可以用局域网或者公网IP/域名访问)  \033[0m \n"
		echo -e " \033[32m 账户密码是showdoc/123456,登录后你便可以看到右上方的管理后台入口。建议登录后修改密码。   \033[0m \n"
		echo -e " \033[32m 对showdoc的问题或建议请至https://github.com/star7th/showdoc 提issue   \033[0m \n"
		echo -e " \033[32m 若觉得showdoc好用,不妨到github点个star。良好的关注度和参与度有助于开源项目的长远发展   \033[0m \n"
	fi



fi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值