mirror of
https://github.com/Ascend/ascend-docker-runtime.git
synced 2025-10-22 12:19:23 +08:00
Match-id-0a51bca7530c8791f9cd6c6b9abb330ef962a99a
This commit is contained in:
5
build/scripts/help.info
Normal file
5
build/scripts/help.info
Normal file
@@ -0,0 +1,5 @@
|
||||
--install Install into this system
|
||||
--install-path Specify the installation path (default: /usr/local/Ascend/Ascend-Docker-Runtime)
|
||||
--uninstall Uninstall the installed ascend-docker-runtime tool
|
||||
--upgrade Upgrade the installed ascend-docker-runtime tool
|
||||
--install-type=<type> Only A500, A200ISoC and A200 need to specify the installation type of Ascend-docker-runtime (eg: --install-type=A500)
|
242
build/scripts/run_main.sh
Normal file
242
build/scripts/run_main.sh
Normal file
@@ -0,0 +1,242 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
|
||||
# Description: ascend-docker-runtime run package script
|
||||
set -e
|
||||
|
||||
ASCEND_RUNTIME_CONFIG_DIR=/etc/ascend-docker-runtime.d
|
||||
DOCKER_CONFIG_DIR=/etc/docker
|
||||
INSTALL_PATH=/usr/local/Ascend/Ascend-Docker-Runtime
|
||||
|
||||
function install()
|
||||
{
|
||||
echo 'installing ascend docker runtime'
|
||||
|
||||
if [ ! -d "${INSTALL_PATH}" ]; then
|
||||
mkdir -p ${INSTALL_PATH}
|
||||
fi
|
||||
if [ -L "${INSTALL_PATH}" ]; then
|
||||
echo "ERROR: ${INSTALL_PATH} is symbolic link."
|
||||
exit 1
|
||||
fi
|
||||
cp -f ./ascend-docker-runtime ${INSTALL_PATH}/ascend-docker-runtime
|
||||
cp -f ./ascend-docker-hook ${INSTALL_PATH}/ascend-docker-hook
|
||||
cp -f ./ascend-docker-cli ${INSTALL_PATH}/ascend-docker-cli
|
||||
cp -f ./ascend-docker-plugin-install-helper ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
cp -f ./ascend-docker-destroy ${INSTALL_PATH}/ascend-docker-destroy
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-runtime
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-hook
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-cli
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-destroy
|
||||
|
||||
if [ -L "${INSTALL_PATH}/script" ]; then
|
||||
echo "ERROR: ${INSTALL_PATH}/script is symbolic link."
|
||||
exit 1
|
||||
fi
|
||||
cp -rf ./assets ${INSTALL_PATH}/assets
|
||||
cp -f ./README.md ${INSTALL_PATH}/README.md
|
||||
mkdir -p ${INSTALL_PATH}/script
|
||||
cp -f ./uninstall.sh ${INSTALL_PATH}/script/uninstall.sh
|
||||
chmod 500 ${INSTALL_PATH}/script/uninstall.sh
|
||||
|
||||
if [ -d "${ASCEND_RUNTIME_CONFIG_DIR}" ]; then
|
||||
rm -rf ${ASCEND_RUNTIME_CONFIG_DIR}
|
||||
fi
|
||||
if [ -L "${ASCEND_RUNTIME_CONFIG_DIR}" ]; then
|
||||
echo "ERROR: ${ASCEND_RUNTIME_CONFIG_DIR} is symbolic link."
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p ${ASCEND_RUNTIME_CONFIG_DIR}
|
||||
chmod 750 ${ASCEND_RUNTIME_CONFIG_DIR}
|
||||
if [ "${a500}" == "y" ]; then
|
||||
cp -f ./base.list_A500 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
elif [ "${a200}" == "y" ]; then
|
||||
cp -f ./base.list_A200 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
elif [ "${a200isoc}" == "y" ]; then
|
||||
cp -f ./base.list_A200ISoC ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
else
|
||||
cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
fi
|
||||
chmod 440 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
|
||||
echo 'install executable files success'
|
||||
|
||||
if [ ! -d "${DOCKER_CONFIG_DIR}" ]; then
|
||||
mkdir -p ${DOCKER_CONFIG_DIR}
|
||||
fi
|
||||
|
||||
SRC="${DOCKER_CONFIG_DIR}/daemon.json.${PPID}"
|
||||
DST="${DOCKER_CONFIG_DIR}/daemon.json"
|
||||
./ascend-docker-plugin-install-helper add ${DST} ${SRC} ${INSTALL_PATH}/ascend-docker-runtime
|
||||
if [ "$?" != "0" ]; then
|
||||
echo 'create damon.json failed'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv ${SRC} ${DST}
|
||||
chmod 600 ${DST}
|
||||
echo 'create damom.json success'
|
||||
echo 'please reboot docker daemon to take effect'
|
||||
}
|
||||
|
||||
function uninstall()
|
||||
{
|
||||
echo 'uninstalling ascend docker runtime'
|
||||
|
||||
if [ ! -d "${INSTALL_PATH}" ]; then
|
||||
echo 'WARNING: the specified install path does not exist, skipping'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${INSTALL_PATH}/script/uninstall.sh
|
||||
echo 'remove daemon.json setting success'
|
||||
|
||||
[ -n "${INSTALL_PATH}" ] && rm -rf ${INSTALL_PATH}
|
||||
echo 'remove executable files success'
|
||||
|
||||
echo 'del damom.json success'
|
||||
}
|
||||
|
||||
function upgrade()
|
||||
{
|
||||
echo 'upgrading ascend docker runtime'
|
||||
|
||||
if [ ! -d "${INSTALL_PATH}" ]; then
|
||||
echo 'ERROR: the specified install path does not exist, stopping upgrading'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "${ASCEND_RUNTIME_CONFIG_DIR}" ]; then
|
||||
echo 'ERROR: the configuration directory does not exist'
|
||||
exit 1
|
||||
fi
|
||||
if [ -L "${INSTALL_PATH}" ]; then
|
||||
echo "ERROR: ${INSTALL_PATH} is symbolic link."
|
||||
exit 1
|
||||
fi
|
||||
cp -f ./ascend-docker-runtime ${INSTALL_PATH}/ascend-docker-runtime
|
||||
cp -f ./ascend-docker-hook ${INSTALL_PATH}/ascend-docker-hook
|
||||
cp -f ./ascend-docker-cli ${INSTALL_PATH}/ascend-docker-cli
|
||||
cp -f ./ascend-docker-plugin-install-helper ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
cp -f ./ascend-docker-destroy ${INSTALL_PATH}/ascend-docker-destroy
|
||||
cp -f ./uninstall.sh ${INSTALL_PATH}/script/uninstall.sh
|
||||
cp -f ./base.list ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-runtime
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-hook
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-cli
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-plugin-install-helper
|
||||
chmod 550 ${INSTALL_PATH}/ascend-docker-destroy
|
||||
chmod 500 ${INSTALL_PATH}/script/uninstall.sh
|
||||
chmod 440 ${ASCEND_RUNTIME_CONFIG_DIR}/base.list
|
||||
|
||||
echo 'upgrade ascend docker runtime success'
|
||||
}
|
||||
|
||||
INSTALL_FLAG=n
|
||||
INSTALL_PATH_FLAG=n
|
||||
UNINSTALL_FLAG=n
|
||||
UPGRADE_FLAG=n
|
||||
a500=n
|
||||
a200=n
|
||||
a200isoc=n
|
||||
|
||||
while true
|
||||
do
|
||||
case "$3" in
|
||||
--install)
|
||||
if [ "${INSTALL_FLAG}" == "y" ]; then
|
||||
echo "warning :Repeat parameter!"
|
||||
exit 1
|
||||
fi
|
||||
INSTALL_FLAG=y
|
||||
shift
|
||||
;;
|
||||
--uninstall)
|
||||
if [ "${UNINSTALL_FLAG}" == "y" ]; then
|
||||
echo "warning :Repeat parameter!"
|
||||
exit 1
|
||||
fi
|
||||
UNINSTALL_FLAG=y
|
||||
shift
|
||||
;;
|
||||
--install-path=*)
|
||||
if [ "${INSTALL_PATH_FLAG}" == "y" ]; then
|
||||
echo "warning :Repeat parameter!"
|
||||
exit 1
|
||||
fi
|
||||
INSTALL_PATH_FLAG=y
|
||||
INSTALL_PATH=$(echo $3 | cut -d"=" -f2)
|
||||
INSTALL_PATH=$(echo ${INSTALL_PATH} | sed "s/\/*$//g")
|
||||
shift
|
||||
;;
|
||||
--upgrade)
|
||||
if [ "${UPGRADE_FLAG}" == "y" ]; then
|
||||
echo "warning :Repeat parameter!"
|
||||
exit 1
|
||||
fi
|
||||
UPGRADE_FLAG=y
|
||||
shift
|
||||
;;
|
||||
--install-type=*)
|
||||
if [ "${a500}" == "y" ] || [ "${a200}" == "y" ] || [ "${a200isoc}" == "y" ]; then
|
||||
echo "warning :Repeat parameter!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$3" == "--install-type=A500" ]; then
|
||||
a500=y
|
||||
elif [ "$3" == "--install-type=A200" ]; then
|
||||
a200=y
|
||||
elif [ "$3" == "--install-type=A200ISoC" ]; then
|
||||
a200isoc=y
|
||||
else
|
||||
echo "ERROR :Please check the parameter of --install-type=<type>"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [ "x$3" != "x" ]; then
|
||||
echo "warning :Unsupported parameters: $3"
|
||||
exit 1
|
||||
fi
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# install path must be absolute path
|
||||
if [[ ! "${INSTALL_PATH}" =~ ^/.* ]]; then
|
||||
echo "ERROR :Please follow the installation address after the --install-path=<Absolute path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# it is not allowed to input only install-path
|
||||
if [ "${INSTALL_PATH_FLAG}" == "y" ] && \
|
||||
[ "${INSTALL_FLAG}" == "n" ] && \
|
||||
[ "${UNINSTALL_FLAG}" == "n" ] && \
|
||||
[ "${UPGRADE_FLAG}" == "n" ]; then
|
||||
echo "Error:only input <install_path> command. When use --install-path you also need intput --install or --uninstall or --upgrade or --devel"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# must run with root permission
|
||||
if [ "${UID}" != "0" ]; then
|
||||
echo 'please run with root permission'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${INSTALL_FLAG}" == "y" ]; then
|
||||
install
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${UNINSTALL_FLAG}" == "y" ]; then
|
||||
uninstall
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${UPGRADE_FLAG}" == "y" ]; then
|
||||
upgrade
|
||||
exit 0
|
||||
fi
|
36
build/scripts/uninstall.sh
Normal file
36
build/scripts/uninstall.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
|
||||
# Description: ascend-docker-runtime uninstall script
|
||||
set -e
|
||||
LOG_FILE="/var/log/ascend_seclog/ascend_toolbox_install.log"
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "start uninstall"
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "start uninstall" >>${LOG_FILE}
|
||||
ROOT=$(cd $(dirname $0); pwd)/..
|
||||
DST='/etc/docker/daemon.json'
|
||||
SRC="${DST}.${PPID}"
|
||||
ASCEND_RUNTIME_CONFIG_DIR=/etc/ascend-docker-runtime.d
|
||||
|
||||
if [ ! -f "${DST}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
${ROOT}/ascend-docker-plugin-install-helper rm ${DST} ${SRC}
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "ERROR: del damon.json failed"
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "ERROR: del damon.json failed" >>${LOG_FILE}
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv ${SRC} ${DST}
|
||||
|
||||
[ -n "${ASCEND_RUNTIME_CONFIG_DIR}" ] && rm -rf ${ASCEND_RUNTIME_CONFIG_DIR}
|
||||
INSTALL_ROOT_PATH=$(dirname $(dirname ${ROOT}))
|
||||
|
||||
if test -d ${INSTALL_ROOT_PATH}
|
||||
then
|
||||
rm -rf ${INSTALL_ROOT_PATH}
|
||||
echo "Ascend-Docker-Runtime $(date +%Y%m%d-%H:%M:%S) delete ${INSTALL_ROOT_PATH} succesfull"
|
||||
echo "Ascend-Docker-Runtime $(date +%Y%m%d-%H:%M:%S) delete ${INSTALL_ROOT_PATH} succesfull" >>${LOG_FILE}
|
||||
fi
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "uninstall successfully"
|
||||
echo "Ascend-Docker-Runtime" $(date +%Y%m%d-%H:%M:%S) "uninstall successfully" >>${LOG_FILE}
|
Reference in New Issue
Block a user