mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-07 15:19:44 +00:00
upload shell script
This commit is contained in:
parent
efd68a6f07
commit
0f6f0aa91d
@ -205,6 +205,7 @@ func Update2_3() {
|
||||
if !file.CheckNotExist("/casaOS") {
|
||||
command.OnlyExec("source /casaOS/server/shell/upload.sh ;")
|
||||
}
|
||||
command.OnlyExec("source /casaOS/server/shell/delete-old-service.sh ;")
|
||||
}
|
||||
func CheckToken2_11() {
|
||||
if len(config.ServerInfo.Token) == 0 {
|
||||
|
||||
104
shell/delete-old-service.sh
Normal file
104
shell/delete-old-service.sh
Normal file
@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
###
|
||||
# @Author: LinkLeong link@icewhale.com
|
||||
# @Date: 2022-06-30 10:08:33
|
||||
# @LastEditors: LinkLeong
|
||||
# @LastEditTime: 2022-06-30 18:14:26
|
||||
# @FilePath: /CasaOS/shell/delete-old-service.sh
|
||||
# @Description:
|
||||
###
|
||||
|
||||
((EUID)) && sudo_cmd="sudo"
|
||||
|
||||
# SYSTEM INFO
|
||||
readonly UNAME_M="$(uname -m)"
|
||||
|
||||
# CasaOS PATHS
|
||||
readonly CASA_REPO=LinkLeong/casaos-alpha
|
||||
readonly CASA_UNZIP_TEMP_FOLDER=/tmp/casaos
|
||||
readonly CASA_BIN=casaos
|
||||
readonly CASA_BIN_PATH=/usr/bin/casaos
|
||||
readonly CASA_CONF_PATH=/etc/casaos.conf
|
||||
readonly CASA_SERVICE_PATH=/etc/systemd/system/casaos.service
|
||||
readonly CASA_HELPER_PATH=/usr/share/casaos/shell/
|
||||
readonly CASA_USER_CONF_PATH=/var/lib/casaos/conf/
|
||||
readonly CASA_DB_PATH=/var/lib/casaos/db/
|
||||
readonly CASA_TEMP_PATH=/var/lib/casaos/temp/
|
||||
readonly CASA_LOGS_PATH=/var/log/casaos/
|
||||
readonly CASA_PACKAGE_EXT=".tar.gz"
|
||||
readonly CASA_RELEASE_API="https://api.github.com/repos/${CASA_REPO}/releases"
|
||||
readonly CASA_OPENWRT_DOCS="https://github.com/IceWhaleTech/CasaOS-OpenWrt"
|
||||
|
||||
readonly COLOUR_RESET='\e[0m'
|
||||
readonly aCOLOUR=(
|
||||
'\e[38;5;154m' # green | Lines, bullets and separators
|
||||
'\e[1m' # Bold white | Main descriptions
|
||||
'\e[90m' # Grey | Credits
|
||||
'\e[91m' # Red | Update notifications Alert
|
||||
'\e[33m' # Yellow | Emphasis
|
||||
)
|
||||
|
||||
Target_Arch=""
|
||||
Target_Distro="debian"
|
||||
Target_OS="linux"
|
||||
Casa_Tag=""
|
||||
|
||||
|
||||
#######################################
|
||||
# Custom printing function
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# $1 0:OK 1:FAILED 2:INFO 3:NOTICE
|
||||
# message
|
||||
# Returns:
|
||||
# None
|
||||
#######################################
|
||||
|
||||
Show() {
|
||||
# OK
|
||||
if (($1 == 0)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
# FAILED
|
||||
elif (($1 == 1)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
# INFO
|
||||
elif (($1 == 2)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
# NOTICE
|
||||
elif (($1 == 3)); then
|
||||
echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2"
|
||||
fi
|
||||
}
|
||||
|
||||
Warn() {
|
||||
echo -e "${aCOLOUR[3]}$1$COLOUR_RESET"
|
||||
}
|
||||
|
||||
# 0 Check_exist
|
||||
Check_Exist() {
|
||||
#Create Dir
|
||||
Show 2 "Create Folders."
|
||||
${sudo_cmd} mkdir -p ${CASA_HELPER_PATH}
|
||||
${sudo_cmd} mkdir -p ${CASA_LOGS_PATH}
|
||||
${sudo_cmd} mkdir -p ${CASA_USER_CONF_PATH}
|
||||
${sudo_cmd} mkdir -p ${CASA_DB_PATH}
|
||||
${sudo_cmd} mkdir -p ${CASA_TEMP_PATH}
|
||||
|
||||
|
||||
Show 2 "Start cleaning up the old version."
|
||||
|
||||
${sudo_cmd} rm -rf /usr/lib/systemd/system/casaos.service
|
||||
|
||||
${sudo_cmd} rm -rf /lib/systemd/system/casaos.service
|
||||
|
||||
${sudo_cmd} rm -rf /usr/local/bin/${CASA_BIN}
|
||||
|
||||
#Clean
|
||||
if [[ -d "/casaOS" ]]; then
|
||||
${sudo_cmd} rm -rf /casaOS
|
||||
fi
|
||||
Show 0 "Clearance completed."
|
||||
|
||||
}
|
||||
Check_Exist
|
||||
@ -3,8 +3,8 @@
|
||||
# @Author: LinkLeong link@icewhale.com
|
||||
# @Date: 2022-06-30 10:08:33
|
||||
# @LastEditors: LinkLeong
|
||||
# @LastEditTime: 2022-06-30 17:13:35
|
||||
# @FilePath: /CasaOS/shell/upload.sh
|
||||
# @LastEditTime: 2022-06-30 18:13:17
|
||||
# @FilePath: /CasaOS/shell/move.sh
|
||||
# @Description:
|
||||
###
|
||||
|
||||
@ -85,22 +85,8 @@ Check_Exist() {
|
||||
${sudo_cmd} mkdir -p ${CASA_DB_PATH}
|
||||
${sudo_cmd} mkdir -p ${CASA_TEMP_PATH}
|
||||
|
||||
if [[ $(systemctl is-active ${CASA_BIN}) == "active" ]]; then
|
||||
${sudo_cmd} systemctl stop ${CASA_BIN}
|
||||
${sudo_cmd} systemctl disable ${CASA_BIN}
|
||||
fi
|
||||
|
||||
Show 2 "Start cleaning up the old version."
|
||||
if [[ -f "/usr/lib/systemd/system/casaos.service" ]]; then
|
||||
${sudo_cmd} rm -rf /usr/lib/systemd/system/casaos.service
|
||||
fi
|
||||
|
||||
if [[ -f "/lib/systemd/system/casaos.service" ]]; then
|
||||
${sudo_cmd} rm -rf /lib/systemd/system/casaos.service
|
||||
fi
|
||||
|
||||
if [[ -f "/usr/local/bin/${CASA_BIN}" ]]; then
|
||||
${sudo_cmd} rm -rf /usr/local/bin/${CASA_BIN}
|
||||
fi
|
||||
|
||||
if [[ -f "/casaOS/server/conf/conf.ini" ]]; then
|
||||
${sudo_cmd} cp -rf /casaOS/server/conf/conf.ini ${CASA_CONF_PATH}
|
||||
@ -139,33 +125,7 @@ Check_Arch() {
|
||||
Show 0 "Your hardware architecture is : $UNAME_M"
|
||||
}
|
||||
|
||||
# Check Docker running
|
||||
Check_Docker_Running() {
|
||||
for ((i = 1; i <= 3; i++)); do
|
||||
sleep 3
|
||||
if [[ ! $(systemctl is-active docker &>/dev/null) ]]; then
|
||||
Show 1 "Docker is not running, try to start"
|
||||
${sudo_cmd} systemctl start docker
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#Install Docker
|
||||
Install_Docker() {
|
||||
Show 0 "Docker will be installed automatically."
|
||||
echo -e "${aCOLOUR[2]}\c"
|
||||
curl -fsSL https://get.docker.com | bash
|
||||
echo -e "${COLOUR_RESET}\c"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
Show 1 "Installation failed, please try again."
|
||||
exit 1
|
||||
else
|
||||
Show 0 "Docker Successfully installed."
|
||||
Check_Docker_Running
|
||||
fi
|
||||
}
|
||||
|
||||
#Download CasaOS Package
|
||||
Download_CasaOS() {
|
||||
@ -288,7 +248,7 @@ Start_CasaOS() {
|
||||
$sudo_cmd systemctl enable ${CASA_BIN}
|
||||
|
||||
Show 2 "Start CasaOS service."
|
||||
$sudo_cmd systemctl start ${CASA_BIN}
|
||||
$sudo_cmd systemctl restart ${CASA_BIN}
|
||||
|
||||
if [[ ! $(systemctl is-active ${CASA_BIN}) == "active" ]]; then
|
||||
Show 1 "Failed to start, please try again."
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user