├── .github └── workflows │ └── release.yml ├── CNAME ├── LICENSE ├── README.md ├── assist.sh ├── casaos-release ├── casaos-tags ├── casaos-uninstall ├── casaos-uninstall.sh ├── casaos.sh ├── cn_install.sh ├── get.sh ├── install.sh ├── uninstall.sh ├── update.sh └── upgrade.sh /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*.*.*" 7 | 8 | jobs: 9 | release: 10 | runs-on: ubuntu-22.04 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v3 14 | with: 15 | fetch-depth: 0 16 | 17 | - name: Get the main tag 18 | id: get_tag 19 | run: echo tag=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT 20 | 21 | - name: Download and consolidate packages 22 | id: package 23 | run: | 24 | MAIN_TAG=${{ steps.get_tag.outputs.tag }} 25 | echo "Main tag: $MAIN_TAG" 26 | 27 | source ./casaos-tags 28 | 29 | mkdir /tmp/packages 30 | pushd /tmp/packages 31 | 32 | # List of architectures 33 | TARGET_ARCH_LIST=("amd64" "arm-7" "arm64") 34 | for TARGET_ARCH in ${TARGET_ARCH_LIST[@]}; do 35 | echo "Downloading packages for $TARGET_ARCH" 36 | URLS=( 37 | "https://github.com/IceWhaleTech/CasaOS-AppManagement/releases/download/${CASAOS_APP_MANAGEMENT_TAG}/linux-${TARGET_ARCH}-casaos-app-management-${CASAOS_APP_MANAGEMENT_TAG}.tar.gz" 38 | "https://github.com/IceWhaleTech/CasaOS-AppStore/releases/download/${CASAOS_APP_STORE_TAG}/linux-all-appstore-${CASAOS_APP_STORE_TAG}.tar.gz" 39 | "https://github.com/IceWhaleTech/CasaOS-CLI/releases/download/${CASAOS_CLI_TAG}/linux-${TARGET_ARCH}-casaos-cli-${CASAOS_CLI_TAG}.tar.gz" 40 | "https://github.com/IceWhaleTech/CasaOS-Gateway/releases/download/${CASAOS_GATEWAY_TAG}/linux-${TARGET_ARCH}-casaos-gateway-${CASAOS_GATEWAY_TAG}.tar.gz" 41 | "https://github.com/IceWhaleTech/CasaOS-LocalStorage/releases/download/${CASAOS_LOCAL_STORAGE_TAG}/linux-${TARGET_ARCH}-casaos-local-storage-${CASAOS_LOCAL_STORAGE_TAG}.tar.gz" 42 | "https://github.com/IceWhaleTech/CasaOS-MessageBus/releases/download/${CASAOS_MESSAGE_BUS_TAG}/linux-${TARGET_ARCH}-casaos-message-bus-${CASAOS_MESSAGE_BUS_TAG}.tar.gz" 43 | "https://github.com/IceWhaleTech/CasaOS-UI/releases/download/${CASAOS_UI_TAG}/linux-all-casaos-${CASAOS_UI_TAG}.tar.gz" 44 | "https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/${CASAOS_USER_SERVICE_TAG}/linux-${TARGET_ARCH}-casaos-user-service-${CASAOS_USER_SERVICE_TAG}.tar.gz" 45 | "https://github.com/IceWhaleTech/CasaOS/releases/download/${CASAOS_TAG}/linux-${TARGET_ARCH}-casaos-${CASAOS_TAG}.tar.gz" 46 | ) 47 | 48 | for URL in ${URLS[@]}; do 49 | echo "Downloading $URL" 50 | wget $URL 51 | done 52 | 53 | tar zcvf casaos-${TARGET_ARCH}-${MAIN_TAG}.tar.gz linux-*.tar.gz 54 | sha256sum casaos-${TARGET_ARCH}-${MAIN_TAG}.tar.gz >> checksums.txt 55 | rm linux-*.tar.gz 56 | done 57 | 58 | - uses: softprops/action-gh-release@v1 59 | if: steps.package.outcome == 'success' 60 | with: 61 | files: | 62 | /tmp/packages/casaos-*.tar.gz 63 | /tmp/packages/checksums.txt 64 | draft: true 65 | prerelease: true 66 | fail_on_unmatched_files: true 67 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | get.icewhale.io -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # get 2 | Installation scripts for IceWhale's products. 3 | 4 | - [./casaos.sh](/casaos.sh) ( [🕵inspect](https://github.com/IceWhaleTech/get/blob/main/casaos.sh) ) – for [CasaOS](https://casaos.io/) 5 | -------------------------------------------------------------------------------- /assist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # @Author: LinkLeong link@icewhale.com 4 | # @Date: 2022-02-17 18:53:29 5 | # @LastEditors: a624669980@163.com a624669980@163.com 6 | # @LastEditTime: 2022-06-30 10:11:31 7 | # @FilePath: /get/assist.sh 8 | # @Description: 9 | # @Website: https://www.casaos.io 10 | # Copyright (c) 2022 by icewhale, All Rights Reserved. 11 | ### 12 | 13 | version_0_2_11() { 14 | sysctl -w net.core.rmem_max=2500000 15 | } 16 | 17 | version_0_2_11 -------------------------------------------------------------------------------- /casaos-release: -------------------------------------------------------------------------------- 1 | version: v0.4.4 2 | release_notes: | 3 | TOOD: add release notes 4 | mirrors: 5 | - http://casaos.io/does/not/exist/test 6 | - https://github.com/IceWhaleTech 7 | packages: 8 | - path: /get/releases/download/v0.4.4-alpha2/casaos-amd64-v0.4.4-alpha2.tar.gz 9 | architecture: amd64 10 | - path: /get/releases/download/v0.4.4-alpha2/casaos-arm64-v0.4.4-alpha2.tar.gz 11 | architecture: arm64 12 | - path: /get/releases/download/v0.4.4-alpha2/casaos-arm-7-v0.4.4-alpha2.tar.gz 13 | architecture: armv7 14 | checksums: /get/releases/download/v0.4.4-alpha2/checksums.txt 15 | modules: 16 | - name: casaos-gateway 17 | short: gateway 18 | - name: casaos-user-service 19 | short: user-service 20 | - name: casaos 21 | short: casaos 22 | - name: casaos-local-storage 23 | short: local-storage 24 | - name: casaos-message-bus 25 | short: message-bus 26 | - name: casaos-app-management 27 | short: app-management 28 | -------------------------------------------------------------------------------- /casaos-tags: -------------------------------------------------------------------------------- 1 | CASAOS_APP_MANAGEMENT_TAG=v0.4.4-alpha16 2 | CASAOS_APP_STORE_TAG=v0.4.4-alpha10 3 | CASAOS_CLI_TAG=v0.4.4-alpha4 4 | CASAOS_GATEWAY_TAG=v0.4.4-alpha1 5 | CASAOS_LOCAL_STORAGE_TAG=v0.4.4-alpha1 6 | CASAOS_MESSAGE_BUS_TAG=v0.4.4-alpha1 7 | CASAOS_TAG=v0.4.4-alpha3 8 | CASAOS_UI_TAG=v0.4.4-alpha19 9 | CASAOS_USER_SERVICE_TAG=v0.4.4-alpha2 10 | -------------------------------------------------------------------------------- /casaos-uninstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # CasaOS Uninstaller Script 4 | # 5 | # GitHub: https://github.com/IceWhaleTech/CasaOS 6 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 7 | # Requires: bash, mv, rm, tr, grep, sed 8 | # 9 | # This script installs CasaOS to your system. 10 | # Usage: 11 | # 12 | # $ curl -fsSL https://get.casaos.io | bash 13 | # or 14 | # $ wget -qO- https://get.casaos.io | bash 15 | # 16 | # In automated environments, you may want to run as root. 17 | # If using curl, we recommend using the -fsSL flags. 18 | # 19 | # This only work on Linux systems. Please 20 | # open an issue if you notice any bugs. 21 | # 22 | set -e 23 | clear 24 | 25 | echo ' 26 | _____ ____ _____ 27 | / ____| / __ \ / ____| 28 | | | __ _ ___ __ _| | | | (___ 29 | | | / _` / __|/ _` | | | |\___ \ 30 | | |___| (_| \__ \ (_| | |__| |____) | 31 | \_____\__,_|___/\__,_|\____/|_____/ 32 | 33 | --- Made by IceWhale with YOU --- 34 | ' 35 | 36 | ############################################################################### 37 | # Golbals # 38 | ############################################################################### 39 | 40 | 41 | # Not every platform has or needs sudo (https://termux.com/linux.html) 42 | ((EUID)) && sudo_cmd="sudo" 43 | 44 | readonly CASA_PATH=/casaOS 45 | readonly CASA_EXEC=casaos 46 | readonly CASA_BIN=/usr/local/bin/casaos 47 | readonly CASA_BIN_NEW=/usr/bin/casaos 48 | readonly CASA_SERVICE_USR=/usr/lib/systemd/system/casaos.service 49 | readonly CASA_SERVICE_LIB=/lib/systemd/system/casaos.service 50 | readonly CASA_SERVICE_ETC=/etc/systemd/system/casaos.service 51 | readonly CASA_ADDON1=/etc/udev/rules.d/11-usb-mount.rules 52 | readonly CASA_ADDON2=/etc/systemd/system/usb-mount@.service 53 | readonly CASA_UNINSTALL_PATH=/usr/bin/casaos-uninstall 54 | 55 | # New Casa Files 56 | readonly CASA_CONF_PATH=/etc/casaos.conf 57 | readonly CASA_USER_FILES=/var/lib/casaos 58 | readonly CASA_LOGS_PATH=/var/log/casaos 59 | readonly CASA_HELPER_PATH=/usr/share/casaos/shell 60 | 61 | 62 | readonly COLOUR_RESET='\e[0m' 63 | readonly aCOLOUR=( 64 | '\e[38;5;154m' # green | Lines, bullets and separators 65 | '\e[1m' # Bold white | Main descriptions 66 | '\e[90m' # Grey | Credits 67 | '\e[91m' # Red | Update notifications Alert 68 | '\e[33m' # Yellow | Emphasis 69 | ) 70 | 71 | readonly GREEN_LINE=" ${aCOLOUR[0]}─────────────────────────────────────────────────────$COLOUR_RESET" 72 | readonly GREEN_BULLET=" ${aCOLOUR[0]}-$COLOUR_RESET" 73 | readonly GREEN_SEPARATOR="${aCOLOUR[0]}:$COLOUR_RESET" 74 | readonly PASSED="${aCOLOUR[0]}PASSED$COLOUR_RESET" 75 | 76 | UNINSTALL_ALL_CONTAINER=false 77 | REMOVE_IMAGES="none" 78 | REMOVE_APP_DATA=false 79 | 80 | ############################################################################### 81 | # Helpers # 82 | ############################################################################### 83 | 84 | ####################################### 85 | # Custom printing function 86 | # Globals: 87 | # None 88 | # Arguments: 89 | # $1 0:OK 1:FAILED 2:INFO 3:NOTICE 90 | # message 91 | # Returns: 92 | # None 93 | ####################################### 94 | 95 | Show() { 96 | # OK 97 | if (($1 == 0)); then 98 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 99 | # FAILED 100 | elif (($1 == 1)); then 101 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 102 | # INFO 103 | elif (($1 == 2)); then 104 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 105 | # NOTICE 106 | elif (($1 == 3)); then 107 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 108 | fi 109 | } 110 | 111 | Warn() { 112 | echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" 113 | } 114 | 115 | trap 'onCtrlC' INT 116 | onCtrlC() { 117 | echo -e "${COLOUR_RESET}" 118 | exit 1 119 | } 120 | 121 | Detecting_CasaOS() { 122 | if [[ ! -x "$(command -v ${CASA_EXEC})" ]]; then 123 | Show 2 "CasaOS is not detected, exit the script." 124 | exit 1 125 | else 126 | Show 0 "This script will delete the containers you no longer use, and the CasaOS configuration files." 127 | fi 128 | } 129 | 130 | Unistall_Container() { 131 | Show 2 "Start deleting containers." 132 | if [[ ${UNINSTALL_ALL_CONTAINER} == true && "$(${sudo_cmd} docker ps -aq)" != "" ]]; then 133 | ${sudo_cmd} docker stop $(${sudo_cmd} docker ps -aq) 134 | ${sudo_cmd} docker rm $(${sudo_cmd} docker ps -aq) 135 | if [[ $? -ne 0 ]]; then 136 | Show 1 "Failed to delete all containers." 137 | else 138 | Show 0 "Successfully deleted all containers." 139 | fi 140 | fi 141 | } 142 | 143 | Remove_Images() { 144 | if [[ ${REMOVE_IMAGES} == "all" && "$(${sudo_cmd} docker images -q)" != "" ]]; then 145 | Show 2 "Start deleting all images." 146 | ${sudo_cmd} docker rmi $(${sudo_cmd} docker images -q) 147 | if [[ $? -ne 0 ]]; then 148 | Show 1 "Failed to delete all images." 149 | else 150 | Show 0 "Successfully deleted all images." 151 | fi 152 | elif [[ ${REMOVE_IMAGES} == "unuse" && "$(${sudo_cmd} docker images -q)" != "" ]]; then 153 | Show 2 "Start deleting unuse images." 154 | ${sudo_cmd} docker image prune -af 155 | if [[ $? -ne 0 ]]; then 156 | Show 1 "Failed to delete unuse images." 157 | else 158 | Show 0 "Successfully deleted all images that are not used by the container." 159 | fi 160 | fi 161 | } 162 | 163 | Uninstall_Casaos() { 164 | 165 | # Stop CasaOS Service 166 | if [[ $(systemctl is-active ${CASA_EXEC}) == "active" ]]; then 167 | ${sudo_cmd} systemctl stop ${CASA_EXEC} 168 | ${sudo_cmd} systemctl disable ${CASA_EXEC} 169 | fi 170 | 171 | # Remove Service file 172 | if [[ -f ${CASA_SERVICE_USR} ]]; then 173 | ${sudo_cmd} rm -rf ${CASA_SERVICE_USR} 174 | fi 175 | 176 | if [[ -f ${CASA_SERVICE_LIB} ]]; then 177 | ${sudo_cmd} rm -rf ${CASA_SERVICE_LIB} 178 | fi 179 | 180 | if [[ -f ${CASA_SERVICE_ETC} ]]; then 181 | ${sudo_cmd} rm -rf ${CASA_SERVICE_ETC} 182 | fi 183 | 184 | # Old Casa Files 185 | if [[ -d ${CASA_PATH} ]]; then 186 | ${sudo_cmd} rm -rf ${CASA_PATH} 187 | if [[ $? -ne 0 ]]; then 188 | Show 1 "Failed to delete CasaOS files." 189 | else 190 | Show 0 "Successfully deleted CasaOS files." 191 | fi 192 | fi 193 | 194 | if [[ -f ${CASA_ADDON1} ]]; then 195 | ${sudo_cmd} rm -rf ${CASA_ADDON1} 196 | fi 197 | 198 | if [[ -f ${CASA_ADDON2} ]]; then 199 | ${sudo_cmd} rm -rf ${CASA_ADDON2} 200 | fi 201 | 202 | if [[ -f ${CASA_BIN} ]]; then 203 | ${sudo_cmd} rm -rf ${CASA_BIN} 204 | if [[ $? -ne 0 ]]; then 205 | Show 1 "Failed to delete CasaOS exec file." 206 | else 207 | Show 0 "Successfully deleted CasaOS exec file." 208 | fi 209 | fi 210 | 211 | # New Casa Files 212 | 213 | if [[ -f ${CASA_CONF_PATH} ]]; then 214 | ${sudo_cmd} rm -rf ${CASA_CONF_PATH} 215 | fi 216 | 217 | if [[ -d ${CASA_USER_FILES} ]]; then 218 | ${sudo_cmd} rm -rf ${CASA_USER_FILES} 219 | fi 220 | 221 | if [[ -d ${CASA_HELPER_PATH} ]]; then 222 | ${sudo_cmd} rm -rf ${CASA_HELPER_PATH} 223 | fi 224 | 225 | if [[ -d ${CASA_LOGS_PATH} ]]; then 226 | ${sudo_cmd} rm -rf ${CASA_LOGS_PATH} 227 | fi 228 | 229 | if [[ -f ${CASA_BIN_NEW} ]]; then 230 | ${sudo_cmd} rm -rf ${CASA_BIN_NEW} 231 | if [[ $? -ne 0 ]]; then 232 | Show 1 "Failed to delete CasaOS exec file." 233 | else 234 | Show 0 "Successfully deleted CasaOS exec file." 235 | fi 236 | fi 237 | 238 | if [[ ${REMOVE_APP_DATA} = true ]]; then 239 | $sudo_cmd rm -fr /DATA/AppData 240 | if [[ $? -ne 0 ]]; then 241 | Show 1 "Failed to delete AppData." 242 | else 243 | Show 0 "Successfully deleted AppData." 244 | fi 245 | fi 246 | 247 | if [[ -f ${CASA_UNINSTALL_PATH} ]]; then 248 | ${sudo_cmd} rm -rf ${CASA_UNINSTALL_PATH} 249 | fi 250 | 251 | } 252 | 253 | #Inputs 254 | 255 | Detecting_CasaOS 256 | 257 | while true; do 258 | echo -n -e " ${aCOLOUR[4]}Do you want delete all containers? Y/n :${COLOUR_RESET}" 259 | read input 260 | case $input in 261 | [yY][eE][sS] | [yY]) 262 | UNINSTALL_ALL_CONTAINER=true 263 | break 264 | ;; 265 | [nN][oO] | [nN]) 266 | UNINSTALL_ALL_CONTAINER=false 267 | break 268 | ;; 269 | *) 270 | Warn " Invalid input..." 271 | ;; 272 | esac 273 | done 274 | 275 | if [[ ${UNINSTALL_ALL_CONTAINER} == true ]]; then 276 | while true; do 277 | echo -n -e " ${aCOLOUR[4]}Do you want delete all images? Y/n :${COLOUR_RESET}" 278 | read input 279 | case $input in 280 | [yY][eE][sS] | [yY]) 281 | REMOVE_IMAGES="all" 282 | break 283 | ;; 284 | [nN][oO] | [nN]) 285 | REMOVE_IMAGES="none" 286 | break 287 | ;; 288 | *) 289 | Warn " Invalid input..." 290 | ;; 291 | esac 292 | done 293 | 294 | while true; do 295 | echo -n -e " ${aCOLOUR[4]}Do you want delete all AppData of CasaOS? Y/n :${COLOUR_RESET}" 296 | read input 297 | case $input in 298 | [yY][eE][sS] | [yY]) 299 | REMOVE_APP_DATA=true 300 | break 301 | ;; 302 | [nN][oO] | [nN]) 303 | REMOVE_APP_DATA=false 304 | break 305 | ;; 306 | *) 307 | Warn " Invalid input..." 308 | ;; 309 | esac 310 | done 311 | else 312 | while true; do 313 | echo -n -e " ${aCOLOUR[4]}Do you want to delete all images that are not used by the container? Y/n :${COLOUR_RESET}" 314 | read input 315 | case $input in 316 | [yY][eE][sS] | [yY]) 317 | REMOVE_IMAGES="unuse" 318 | break 319 | ;; 320 | [nN][oO] | [nN]) 321 | REMOVE_IMAGES="none" 322 | break 323 | ;; 324 | *) 325 | Warn " Invalid input..." 326 | ;; 327 | esac 328 | done 329 | fi 330 | 331 | Unistall_Container 332 | Remove_Images 333 | Uninstall_Casaos 334 | -------------------------------------------------------------------------------- /casaos-uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # CasaOS Uninstaller Script 4 | # 5 | # GitHub: https://github.com/IceWhaleTech/CasaOS 6 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 7 | # Requires: bash, mv, rm, tr, type, grep, sed, curl/wget, tar 8 | # 9 | # This script uninstalls CasaOS to your path. 10 | # Usage: 11 | # 12 | # $ curl -fsSL https://get.icewhale.io/uninstall.sh | bash 13 | # or 14 | # $ wget -qO- https://get.icewhale.io/uninstall.sh | bash 15 | # 16 | # In automated environments, you may want to run as root. 17 | # If using curl, we recommend using the -fsSL flags. 18 | # 19 | # This should work on Mac, Linux, and BSD systems. Please 20 | # open an issue if you notice any bugs. 21 | # 22 | 23 | clear 24 | 25 | ############################################################################### 26 | # Golbals # 27 | ############################################################################### 28 | 29 | UNSTALL_DOCKER=false 30 | REMOVE_CASAOS_FILES=false 31 | REMOVE_CASAOS_CONTAINERS=false 32 | 33 | readonly TITLE="CasaOS Uninstaller" 34 | 35 | readonly CASA_PATH=/casaOS/server 36 | 37 | readonly casa_bin="casaos" 38 | install_path="/usr/local/bin" 39 | service_path=/usr/lib/systemd/system/casaos.service 40 | if [ ! -d "/usr/lib/systemd/system" ]; then 41 | service_path=/lib/systemd/system/casaos.service 42 | if [ ! -d "/lib/systemd/system" ]; then 43 | service_path=/etc/systemd/system/casaos.service 44 | fi 45 | fi 46 | 47 | ############################################################################### 48 | # Helpers # 49 | ############################################################################### 50 | 51 | ####################################### 52 | # Check and install whiptail function 53 | # Globals: 54 | # None 55 | # Arguments: 56 | # None 57 | # Returns: 58 | # None 59 | ####################################### 60 | 61 | install_whiptail() { 62 | 63 | if [ -x "$(command -v whiptail)" ]; then 64 | echo "" 65 | else 66 | if [[ -r /etc/os-release ]]; then 67 | lsb_dist="$(. /etc/os-release && echo "$ID")" 68 | fi 69 | if [[ $lsb_dist == "openwrt" ]]; then 70 | opkg update 71 | opkg install whiptail 72 | #exit 1 73 | elif [[ $lsb_dist == "debian" ]] || [[ $lsb_dist == "ubuntu" ]] || [[ $lsb_dist == "raspbian" ]]; then 74 | ((EUID)) && sudo_cmd="sudo" 75 | $sudo_cmd apt -y update 76 | $sudo_cmd apt -y install whiptail 77 | elif [[ $lsb_dist == "centos" ]]; then 78 | yum update 79 | yum install newt 80 | fi 81 | fi 82 | } 83 | 84 | ####################################### 85 | # Uninstall Docker 86 | # Globals: 87 | # None 88 | # Arguments: 89 | # None 90 | # Returns: 91 | # None 92 | ####################################### 93 | 94 | uninstall_docker() { 95 | if [[ $UNSTALL_DOCKER = true ]]; then 96 | ((EUID)) && sudo_cmd="sudo" 97 | $sudo_cmd apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-scan-plugin 98 | $sudo_cmd apt-get autoremove -y --purge docker-engine docker docker.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-scan-plugin 99 | 100 | $sudo_cmd rm -rf /var/lib/docker /etc/docker 101 | $sudo_cmd rm /etc/apparmor.d/docker 102 | $sudo_cmd groupdel docker 103 | $sudo_cmd rm -rf /var/run/docker.sock 104 | fi 105 | } 106 | 107 | ####################################### 108 | # Uninstall CasaOS 109 | # Globals: 110 | # None 111 | # Arguments: 112 | # None 113 | # Returns: 114 | # None 115 | ####################################### 116 | 117 | uninstall_casaos() { 118 | ((EUID)) && sudo_cmd="sudo" 119 | 120 | #stop and remove casaos service 121 | remove_serveice $service_path $install_path/casaos 122 | 123 | #remove casa containers 124 | if [[ $REMOVE_CASAOS_CONTAINERS = true ]]; then 125 | #stop all casaos‘s containers 126 | official_containers=$($sudo_cmd docker ps -a -q -f "label=origin=official") 127 | $sudo_cmd docker stop $official_containers 128 | $sudo_cmd docker rm $official_containers 129 | 130 | custom_containers=$($sudo_cmd docker ps -a -q -f "label=origin=custom") 131 | $sudo_cmd docker stop $custom_containers 132 | $sudo_cmd docker rm $custom_containers 133 | 134 | system_containers=$($sudo_cmd docker ps -a -q -f "label=origin=system") 135 | $sudo_cmd docker stop $system_containers 136 | $sudo_cmd docker rm $system_containers 137 | 138 | #remove all unuse images 139 | $sudo_cmd docker image prune -f 140 | 141 | fi 142 | 143 | #remove casa files 144 | if [[ $REMOVE_CASAOS_FILES = true ]]; then 145 | $sudo_cmd rm -fr /casaOS 146 | fi 147 | 148 | } 149 | 150 | ####################################### 151 | # Custom printing function 152 | # Globals: 153 | # None 154 | # Arguments: 155 | # $1 0:OK 1:FAILED 156 | # message 157 | # Returns: 158 | # None 159 | ####################################### 160 | 161 | show() { 162 | local color=("$@") output grey green red reset 163 | if [[ -t 0 || -t 1 ]]; then 164 | output='\e[0m\r\e[J' grey='\e[90m' green='\e[32m' red='\e[31m' reset='\e[0m' 165 | fi 166 | local left="${grey}[$reset" right="$grey]$reset" 167 | local ok="$left$green OK $right " failed="$left${red}FAILED$right " info="$left$green INFO $right " 168 | # Print color array from index $1 169 | Print() { 170 | [[ $1 == 1 ]] 171 | for ((i = $1; i < ${#color[@]}; i++)); do 172 | output+=${color[$i]} 173 | done 174 | echo -ne "$output$reset" 175 | } 176 | 177 | if (($1 == 0)); then 178 | output+=$ok 179 | color+=('\n') 180 | Print 1 181 | 182 | elif (($1 == 1)); then 183 | output+=$failed 184 | color+=('\n') 185 | Print 1 186 | 187 | elif (($1 == 2)); then 188 | output+=$info 189 | color+=('\n') 190 | Print 1 191 | fi 192 | } 193 | 194 | ####################################### 195 | # Custom remove casaos function 196 | # Globals: 197 | # None 198 | # Arguments: 199 | # None 200 | # Returns: 201 | # None 202 | ####################################### 203 | remove_directory() { 204 | ((EUID)) && sudo_cmd="sudo" 205 | $sudo_cmd rm -fr /casaOS 206 | } 207 | 208 | ####################################### 209 | # Custom remove data directory function 210 | # Globals: 211 | # None 212 | # Arguments: 213 | # None 214 | # Returns: 215 | # None 216 | ####################################### 217 | remove_DATA_directory() { 218 | ((EUID)) && sudo_cmd="sudo" 219 | $sudo_cmd rm -fr /DATA 220 | } 221 | 222 | ####################################### 223 | # Custom remove casaos function 224 | # Globals: 225 | # None 226 | # Arguments: 227 | # $1 0:service path 1:casaos path 228 | # Returns: 229 | # None 230 | ####################################### 231 | remove_serveice() { 232 | ((EUID)) && sudo_cmd="sudo" 233 | $sudo_cmd systemctl disable casaos 234 | if [ -f $service_path ]; then 235 | show 2 "Try stop CasaOS system service." 236 | $sudo_cmd systemctl stop casaos.service # Stop before generation 237 | fi 238 | $sudo_cmd rm $1 239 | $sudo_cmd rm $2 240 | } 241 | 242 | install_whiptail 243 | 244 | if (whiptail --title "${TITLE}" --yesno --defaultno "Do you want uninstall docker?" 10 60); then 245 | UNSTALL_DOCKER=true 246 | else 247 | if (whiptail --title "${TITLE}" --yesno --defaultno "Do you want remove all containers of CasaOS?" 10 60); then 248 | REMOVE_CASAOS_CONTAINERS=true 249 | fi 250 | fi 251 | 252 | if (whiptail --title "${TITLE}" --yesno --defaultno "Do you want remove all files of CasaOS?" 10 60); then 253 | REMOVE_CASAOS_FILES=true 254 | fi 255 | 256 | uninstall_docker 257 | 258 | uninstall_casaos 259 | 260 | whiptail --title "${TITLE}" --msgbox " Uninstall succeed! \n The '/DATA' directory and docker need to be uninstalled manually." 10 60 261 | -------------------------------------------------------------------------------- /casaos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # CasaOS Installer Script 4 | # 5 | # GitHub: https://github.com/IceWhaleTech/CasaOS 6 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 7 | # Requires: bash, mv, rm, tr, grep, sed, curl/wget, tar, smartmontools, parted, ntfs-3g, net-tools 8 | # 9 | # This script installs CasaOS to your system. 10 | # Usage: 11 | # 12 | # $ curl -fsSL https://get.casaos.io | bash 13 | # or 14 | # $ wget -qO- https://get.casaos.io | bash 15 | # 16 | # In automated environments, you may want to run as root. 17 | # If using curl, we recommend using the -fsSL flags. 18 | # 19 | # This only work on Linux systems. Please 20 | # open an issue if you notice any bugs. 21 | # 22 | 23 | clear 24 | 25 | echo ' 26 | _____ ____ _____ 27 | / ____| / __ \ / ____| 28 | | | __ _ ___ __ _| | | | (___ 29 | | | / _` / __|/ _` | | | |\___ \ 30 | | |___| (_| \__ \ (_| | |__| |____) | 31 | \_____\__,_|___/\__,_|\____/|_____/ 32 | 33 | --- Made by IceWhale with YOU --- 34 | ' 35 | 36 | ############################################################################### 37 | # Golbals # 38 | ############################################################################### 39 | 40 | # Not every platform has or needs sudo (https://termux.com/linux.html) 41 | ((EUID)) && sudo_cmd="sudo" 42 | 43 | readonly TITLE="CasaOS Installer" 44 | # SYSTEM REQUIREMENTS 45 | readonly MINIMUM_DISK_SIZE_GB="5" 46 | readonly MINIMUM_MEMORY="400" 47 | readonly MINIMUM_DOCER_VERSION="20" 48 | readonly SUPPORTED_DIST=('debian' 'ubuntu' 'raspbian') 49 | readonly CASA_DEPANDS_PACKAGE=('curl' 'smartmontools' 'parted' 'ntfs-3g' 'net-tools' 'whiptail' 'udevil' 'samba' 'cifs-utils') 50 | readonly CASA_DEPANDS_COMMAND=('curl' 'smartctl' 'parted' 'ntfs-3g' 'netstat' 'whiptail' 'udevil' 'samba' 'mount.cifs') 51 | 52 | # SYSTEM INFO 53 | readonly PHYSICAL_MEMORY=$(LC_ALL=C free -m | awk '/Mem:/ { print $2 }') 54 | readonly FREE_DISK_BYTES=$(LC_ALL=C df -P / | tail -n 1 | awk '{print $4}') 55 | readonly FREE_DISK_GB=$((${FREE_DISK_BYTES} / 1024 / 1024)) 56 | readonly LSB_DIST="$(. /etc/os-release && echo "$ID")" 57 | readonly LSB_DIST_LIKE="$(. /etc/os-release && echo "$ID_LIKE")" 58 | readonly UNAME_M="$(uname -m)" 59 | readonly UNAME_U="$(uname -s)" 60 | 61 | # CasaOS PATHS 62 | readonly CASA_REPO=IceWhaleTech/CasaOS 63 | readonly CASA_UNZIP_TEMP_FOLDER=/tmp/casaos 64 | readonly CASA_BIN=casaos 65 | readonly CASA_BIN_PATH=/usr/bin/casaos 66 | readonly CASA_CONF_PATH=/etc/casaos.conf 67 | readonly CASA_SERVICE_PATH=/etc/systemd/system/casaos.service 68 | readonly CASA_HELPER_PATH=/usr/share/casaos/shell/ 69 | readonly CASA_USER_CONF_PATH=/var/lib/casaos/conf/ 70 | readonly CASA_DB_PATH=/var/lib/casaos/db/ 71 | readonly CASA_TEMP_PATH=/var/lib/casaos/temp/ 72 | readonly CASA_LOGS_PATH=/var/log/casaos/ 73 | readonly CASA_PACKAGE_EXT=".tar.gz" 74 | readonly CASA_RELEASE_API="https://api.github.com/repos/${CASA_REPO}/releases" 75 | readonly CASA_OPENWRT_DOCS="https://github.com/IceWhaleTech/CasaOS-OpenWrt" 76 | readonly CASA_UNINSTALL_URL="https://raw.githubusercontent.com/IceWhaleTech/get/main/casaos-uninstall" 77 | readonly CASA_VERSION_URL="https://api.casaos.io/casaos-api/version" 78 | readonly CASA_UNINSTALL_PATH=/usr/bin/casaos-uninstall 79 | 80 | # DEPANDS CONF PATH 81 | readonly UDEVIL_CONF_PATH=/etc/udevil/udevil.conf 82 | 83 | readonly COLOUR_RESET='\e[0m' 84 | readonly aCOLOUR=( 85 | '\e[38;5;154m' # green | Lines, bullets and separators 86 | '\e[1m' # Bold white | Main descriptions 87 | '\e[90m' # Grey | Credits 88 | '\e[91m' # Red | Update notifications Alert 89 | '\e[33m' # Yellow | Emphasis 90 | ) 91 | 92 | readonly GREEN_LINE=" ${aCOLOUR[0]}─────────────────────────────────────────────────────$COLOUR_RESET" 93 | readonly GREEN_BULLET=" ${aCOLOUR[0]}-$COLOUR_RESET" 94 | readonly GREEN_SEPARATOR="${aCOLOUR[0]}:$COLOUR_RESET" 95 | readonly PASSED="${aCOLOUR[0]}PASSED$COLOUR_RESET" 96 | 97 | Port=80 98 | Target_Arch="" 99 | Target_Distro="debian" 100 | Target_OS="linux" 101 | Casa_Tag="" 102 | 103 | trap 'onCtrlC' INT 104 | onCtrlC() { 105 | echo -e "${COLOUR_RESET}" 106 | exit 1 107 | } 108 | 109 | ############################################################################### 110 | # Helpers # 111 | ############################################################################### 112 | 113 | #Usage 114 | usage() { 115 | cat <<-EOF 116 | Usage: get.sh [options] 117 | Valid options are: 118 | -v Specify version to install For example: get.sh -v v0.2.3 | get.sh -v pre | get.sh 119 | -h Show this help message and exit 120 | EOF 121 | exit $1 122 | } 123 | 124 | ####################################### 125 | # Custom printing function 126 | # Globals: 127 | # None 128 | # Arguments: 129 | # $1 0:OK 1:FAILED 2:INFO 3:NOTICE 130 | # message 131 | # Returns: 132 | # None 133 | ####################################### 134 | 135 | Show() { 136 | # OK 137 | if (($1 == 0)); then 138 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 139 | # FAILED 140 | elif (($1 == 1)); then 141 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 142 | # INFO 143 | elif (($1 == 2)); then 144 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 145 | # NOTICE 146 | elif (($1 == 3)); then 147 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 148 | fi 149 | } 150 | 151 | Warn() { 152 | echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" 153 | } 154 | 155 | Clear_Term() { 156 | 157 | # Without an input terminal, there is no point in doing this. 158 | [[ -t 0 ]] || return 159 | 160 | # Printing terminal height - 1 newlines seems to be the fastest method that is compatible with all terminal types. 161 | local lines=$(tput lines) i newlines 162 | for ((i = 1; i < ${lines% *}; i++)); do newlines+='\n'; done 163 | echo -ne "\e[0m$newlines\e[H" 164 | 165 | } 166 | 167 | exist_file() { 168 | if [ -e "$1" ]; then 169 | return 1 170 | else 171 | return 2 172 | fi 173 | } 174 | 175 | # 0 Check_exist 176 | Check_Exist() { 177 | #Create Dir 178 | Show 2 "Create folders." 179 | ${sudo_cmd} mkdir -p ${CASA_HELPER_PATH} 180 | ${sudo_cmd} mkdir -p ${CASA_LOGS_PATH} 181 | ${sudo_cmd} mkdir -p ${CASA_USER_CONF_PATH} 182 | ${sudo_cmd} mkdir -p ${CASA_DB_PATH} 183 | ${sudo_cmd} mkdir -p ${CASA_TEMP_PATH} 184 | 185 | if [[ $(systemctl is-active ${CASA_BIN}) == "active" ]]; then 186 | ${sudo_cmd} systemctl stop ${CASA_BIN} 187 | ${sudo_cmd} systemctl disable ${CASA_BIN} 188 | fi 189 | Show 2 "Start cleaning up the old version." 190 | if [[ -f "/usr/lib/systemd/system/casaos.service" ]]; then 191 | ${sudo_cmd} rm -rf /usr/lib/systemd/system/casaos.service 192 | fi 193 | 194 | if [[ -f "/lib/systemd/system/casaos.service" ]]; then 195 | ${sudo_cmd} rm -rf /lib/systemd/system/casaos.service 196 | fi 197 | 198 | if [[ -f "/usr/local/bin/${CASA_BIN}" ]]; then 199 | ${sudo_cmd} rm -rf /usr/local/bin/${CASA_BIN} 200 | fi 201 | 202 | if [[ -f "/casaOS/server/conf/conf.ini" ]]; then 203 | ${sudo_cmd} cp -rf /casaOS/server/conf/conf.ini ${CASA_CONF_PATH} 204 | exist_file /casaOS/server/conf/*.json 205 | value=$? 206 | if [ $value -eq 1 ]; then 207 | ${sudo_cmd} cp -rf /casaOS/server/conf/*.json ${CASA_USER_CONF_PATH} 208 | fi 209 | fi 210 | 211 | if [[ -d "/casaOS/server/db" ]]; then 212 | ${sudo_cmd} cp -rf /casaOS/server/db/* ${CASA_DB_PATH} 213 | fi 214 | 215 | if [[ -f ${CASA_UNINSTALL_PATH} ]]; then 216 | ${sudo_cmd} rm -rf ${CASA_UNINSTALL_PATH} 217 | fi 218 | 219 | #Clean 220 | if [[ -d "/casaOS" ]]; then 221 | ${sudo_cmd} rm -rf /casaOS 222 | fi 223 | Show 0 "Clearance completed." 224 | 225 | } 226 | 227 | # 1 Check Arch 228 | Check_Arch() { 229 | case $UNAME_M in 230 | *aarch64*) 231 | Target_Arch="arm64" 232 | ;; 233 | *riscv64*) 234 | Target_Arch="riscv64" 235 | ;; 236 | *64*) 237 | Target_Arch="amd64" 238 | ;; 239 | *armv7*) 240 | Target_Arch="arm-7" 241 | ;; 242 | *) 243 | Show 1 "Aborted, unsupported or unknown architecture: $UNAME_M" 244 | exit 1 245 | ;; 246 | esac 247 | Show 0 "Your hardware architecture is : $UNAME_M" 248 | } 249 | 250 | # 2 Check Distribution 251 | Check_Distribution() { 252 | sType=0 253 | notice="" 254 | case $LSB_DIST in 255 | *debian*) 256 | Target_Distro="debian" 257 | ;; 258 | *ubuntu*) 259 | Target_Distro="ubuntu" 260 | ;; 261 | *raspbian*) 262 | Target_Distro="raspbian" 263 | ;; 264 | *openwrt*) 265 | Show 1 "Aborted, OpenWrt cannot be installed using this script, please visit ${CASA_OPENWRT_DOCS}." 266 | exit 1 267 | ;; 268 | *alpine*) 269 | Show 1 "Aborted, Alpine installation is not yet supported." 270 | exit 1 271 | ;; 272 | *trisquel*) 273 | Target_Distro="debian" 274 | ;; 275 | *) 276 | sType=1 277 | notice="We have not tested it on this system and it may fail to install." 278 | ;; 279 | esac 280 | Show $sType "Your Linux Distribution is : $LSB_DIST $notice" 281 | if [[ $sType == 1 ]]; then 282 | if (whiptail --title "${TITLE}" --yesno --defaultno "Your Linux Distribution is : $LSB_DIST $notice. Continue installation?" 10 60); then 283 | Show 0 "Distribution check has been ignored." 284 | else 285 | Show 1 "Already exited the installation." 286 | exit 1 287 | fi 288 | fi 289 | } 290 | 291 | # 3 Check OS 292 | Check_OS() { 293 | if [[ $UNAME_U == *Linux* ]]; then 294 | Target_OS="linux" 295 | Show 0 "Your System is : $UNAME_U" 296 | else 297 | Show 1 "Aborted, Support Linux system only." 298 | exit 1 299 | fi 300 | } 301 | 302 | # Check Memory 303 | Check_Memory() { 304 | if [[ "${PHYSICAL_MEMORY}" -lt "${MINIMUM_MEMORY}" ]]; then 305 | Show 1 "requires atleast 1GB physical memory." 306 | exit 1 307 | fi 308 | Show 0 "Memory capacity check passed." 309 | } 310 | 311 | # Check Disk 312 | 313 | Check_Disk() { 314 | if [[ "${FREE_DISK_GB}" -lt "${MINIMUM_DISK_SIZE_GB}" ]]; then 315 | if (whiptail --title "${TITLE}" --yesno --defaultno "Recommended free disk space is greater than \e[33m${MINIMUM_DISK_SIZE_GB}GB\e[0m, Current free disk space is \e[33m${FREE_DISK_GB}GB.Continue installation?" 10 60); then 316 | Show 0 "Disk capacity check has been ignored." 317 | else 318 | Show 1 "Already exited the installation." 319 | exit 1 320 | fi 321 | else 322 | Show 0 "Disk capacity check passed." 323 | fi 324 | } 325 | 326 | # Check Port Use 327 | Check_Port() { 328 | TCPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l) 329 | UDPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "udp" && $NF == "0.0.0.0:*" {print $0}' | wc -l) 330 | ((Listeningnum = TCPListeningnum + UDPListeningnum)) 331 | if [[ $Listeningnum == 0 ]]; then 332 | echo "0" 333 | else 334 | echo "1" 335 | fi 336 | } 337 | 338 | # Get an available port 339 | Get_Port() { 340 | CurrentPort=$(${sudo_cmd} cat ${CASA_CONF_PATH} | grep HttpPort | awk '{print $3}') 341 | if [[ $CurrentPort == $Port ]]; then 342 | for PORT in {80..65536}; do 343 | if [[ $(Check_Port $PORT) == 0 ]]; then 344 | Port=$PORT 345 | break 346 | fi 347 | done 348 | else 349 | Port=$CurrentPort 350 | fi 351 | } 352 | 353 | # Update package 354 | 355 | Update_Package_Resource() { 356 | if [ -x "$(command -v apk)" ]; then 357 | ${sudo_cmd} apk update 358 | elif [ -x "$(command -v apt-get)" ]; then 359 | ${sudo_cmd} apt-get update 360 | elif [ -x "$(command -v dnf)" ]; then 361 | ${sudo_cmd} dnf check-update 362 | elif [ -x "$(command -v zypper)" ]; then 363 | ${sudo_cmd} zypper update 364 | elif [ -x "$(command -v yum)" ]; then 365 | ${sudo_cmd} yum update 366 | fi 367 | } 368 | 369 | # Install depends package 370 | Install_Depends() { 371 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 372 | cmd=${CASA_DEPANDS_COMMAND[i]} 373 | if [[ ! -x "$(command -v $cmd)" ]]; then 374 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 375 | Show 2 "Install the necessary dependencies: \e[33m$packagesNeeded \e[0m" 376 | echo -e "${aCOLOUR[2]}\c" 377 | if [ -x "$(command -v apk)" ]; then 378 | ${sudo_cmd} apk add --no-cache $packagesNeeded 379 | elif [ -x "$(command -v apt-get)" ]; then 380 | ${sudo_cmd} apt-get -y -q install $packagesNeeded --no-upgrade 381 | elif [ -x "$(command -v dnf)" ]; then 382 | ${sudo_cmd} dnf install $packagesNeeded 383 | elif [ -x "$(command -v zypper)" ]; then 384 | ${sudo_cmd} zypper install $packagesNeeded 385 | elif [ -x "$(command -v yum)" ]; then 386 | ${sudo_cmd} yum install $packagesNeeded 387 | elif [ -x "$(command -v pacman)" ]; then 388 | ${sudo_cmd} pacman -S $packagesNeeded 389 | elif [ -x "$(command -v paru)" ]; then 390 | ${sudo_cmd} paru -S $packagesNeeded 391 | else 392 | Show 1 "Package manager not found. You must manually install: \e[33m$packagesNeeded \e[0m" 393 | fi 394 | echo -e "${COLOUR_RESET}\c" 395 | fi 396 | done 397 | } 398 | 399 | Check_Dependency_Installation() { 400 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 401 | cmd=${CASA_DEPANDS_COMMAND[i]} 402 | if [[ ! -x "$(command -v $cmd)" ]]; then 403 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 404 | Show 1 "Dependency \e[33m$packagesNeeded \e[0m installation failed, please try again manually!" 405 | exit 1 406 | fi 407 | done 408 | } 409 | 410 | # Check Docker running 411 | Check_Docker_Running() { 412 | for ((i = 1; i <= 3; i++)); do 413 | sleep 3 414 | if [[ ! $(${sudo_cmd} systemctl is-active docker) == "active" ]]; then 415 | Show 1 "Docker is not running, try to start" 416 | ${sudo_cmd} systemctl start docker 417 | else 418 | break 419 | fi 420 | done 421 | } 422 | 423 | # Check Docker installed 424 | Check_Docker_Install_Final() { 425 | if [[ -x "$(command -v docker)" ]]; then 426 | Docker_Version=$(${sudo_cmd} docker version --format '{{.Server.Version}}') 427 | if [[ $? -ne 0 ]]; then 428 | Install_Docker 429 | elif [[ ${Docker_Version:0:2} -lt "${MINIMUM_DOCER_VERSION}" ]]; then 430 | Show 1 "Recommended minimum Docker version is \e[33m${MINIMUM_DOCER_VERSION}.xx.xx\e[0m,\Current Docker verison is \e[33m${Docker_Version}\e[0m,\nPlease uninstall current Docker and rerun the CasaOS installation script." 431 | exit 1 432 | else 433 | Show 0 "Current Docker verison is ${Docker_Version}." 434 | Check_Docker_Running 435 | fi 436 | else 437 | Show 1 "Installation failed, please run 'curl -fsSL https://get.docker.com | bash' and rerun the CasaOS installation script." 438 | exit 1 439 | fi 440 | } 441 | 442 | #Install Docker 443 | Install_Docker() { 444 | Show 0 "Docker will be installed automatically." 445 | echo -e "${aCOLOUR[2]}\c" 446 | curl -fsSL https://get.docker.com | bash 447 | echo -e "${COLOUR_RESET}\c" 448 | if [[ $? -ne 0 ]]; then 449 | Show 1 "Installation failed, please try again." 450 | exit 1 451 | else 452 | Check_Docker_Install_Final 453 | fi 454 | } 455 | 456 | #Check Docker Installed and version 457 | Check_Docker_Install() { 458 | if [[ -x "$(command -v docker)" ]]; then 459 | Docker_Version=$(${sudo_cmd} docker version --format '{{.Server.Version}}') 460 | if [[ $? -ne 0 ]]; then 461 | Install_Docker 462 | elif [[ ${Docker_Version:0:2} -lt "${MINIMUM_DOCER_VERSION}" ]]; then 463 | Show 1 "Recommended minimum Docker version is \e[33m${MINIMUM_DOCER_VERSION}.xx.xx\e[0m,\Current Docker verison is \e[33m${Docker_Version}\e[0m,\nPlease uninstall current Docker and rerun the CasaOS installation script." 464 | exit 1 465 | else 466 | Show 0 "Current Docker verison is ${Docker_Version}." 467 | fi 468 | else 469 | Install_Docker 470 | fi 471 | } 472 | 473 | #Download CasaOS Package 474 | Download_CasaOS() { 475 | Show 2 "Downloading CasaOS for ${Target_OS}/${Target_Arch}..." 476 | Net_Getter="curl -fsSLk" 477 | Casa_Package="${Target_OS}-${Target_Arch}-casaos${CASA_PACKAGE_EXT}" 478 | if [[ ! -n "$version" ]]; then 479 | Casa_Tag="v$(${Net_Getter} ${CASA_VERSION_URL})" 480 | elif [[ $version == "pre" ]]; then 481 | Casa_Tag="$(${net_getter} ${CASA_RELEASE_API} | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g' | sed -n '1p')" 482 | else 483 | Casa_Tag="$version" 484 | fi 485 | Casa_Package_URL="https://github.com/${CASA_REPO}/releases/download/${Casa_Tag}/${Casa_Package}" 486 | # Remove Temp File 487 | ${sudo_cmd} rm -rf "$PREFIX/tmp/${Casa_Package}" 488 | # Download Package 489 | ${sudo_cmd} ${Net_Getter} "${Casa_Package_URL}" >"$PREFIX/tmp/${Casa_Package}" 490 | if [[ $? -ne 0 ]]; then 491 | Show 1 "Download failed, Please check if your internet connection is working and retry." 492 | exit 1 493 | else 494 | Show 0 "Download successful!" 495 | fi 496 | #Extract CasaOS Package 497 | Show 2 "Extracting..." 498 | case "${Casa_Package}" in 499 | *.zip) ${sudo_cmd} unzip -o "$PREFIX/tmp/${Casa_Package}" -d "$PREFIX/tmp/" ;; 500 | *.tar.gz) ${sudo_cmd} tar -xzf "$PREFIX/tmp/${Casa_Package}" -C "$PREFIX/tmp/" ;; 501 | esac 502 | #Setting Executable Permissions 503 | ${sudo_cmd} chmod +x "$PREFIX${CASA_UNZIP_TEMP_FOLDER}/${CASA_BIN}" 504 | 505 | #Download Uninstall Script 506 | if [[ -f $PREFIX/tmp/casaos-uninstall ]]; then 507 | ${sudo_cmd} rm -rf $PREFIX/tmp/casaos-uninstall 508 | fi 509 | ${sudo_cmd} ${Net_Getter} "$CASA_UNINSTALL_URL" >"$PREFIX/tmp/casaos-uninstall" 510 | ${sudo_cmd} cp -rf "$PREFIX/tmp/casaos-uninstall" $CASA_UNINSTALL_PATH 511 | if [[ $? -ne 0 ]]; then 512 | Show 1 "Download uninstall script failed, Please check if your internet connection is working and retry." 513 | exit 1 514 | fi 515 | ${sudo_cmd} chmod +x $CASA_UNINSTALL_PATH 516 | 517 | } 518 | 519 | #Install Addons 520 | Install_Addons() { 521 | Show 2 "Installing CasaOS Addons" 522 | # ${sudo_cmd} cp -rf "$PREFIX${CASA_UNZIP_TEMP_FOLDER}/shell/11-usb-mount.rules" "/etc/udev/rules.d/" 523 | # ${sudo_cmd} cp -rf "$PREFIX${CASA_UNZIP_TEMP_FOLDER}/shell/usb-mount@.service" "/etc/systemd/system/" 524 | sync 525 | } 526 | 527 | #Configuration Addons 528 | Configuration_Addons() { 529 | Show 2 "Configuration CasaOS Addons" 530 | #Remove old udev rules 531 | if [[ -f $PREFIX/etc/udev/rules.d/11-usb-mount.rules ]]; then 532 | ${sudo_cmd} rm -rf $PREFIX/etc/udev/rules.d/11-usb-mount.rules 533 | fi 534 | 535 | if [[ -f $PREFIX/etc/systemd/system/usb-mount@.service ]]; then 536 | ${sudo_cmd} rm -rf $PREFIX/etc/systemd/system/usb-mount@.service 537 | fi 538 | 539 | 540 | #Udevil 541 | if [[ -f $PREFIX${UDEVIL_CONF_PATH} ]]; then 542 | 543 | #Change udevil mount dir to /DATA 544 | ${sudo_cmd} sed -i 's/allowed_media_dirs = \/media\/$USER, \/run\/media\/$USER/allowed_media_dirs = \/DATA, \/DATA\/$USER/g' $PREFIX${UDEVIL_CONF_PATH} 545 | 546 | # Add a devmon user 547 | ${sudo_cmd} useradd -M -u 300 devmon 548 | ${sudo_cmd} usermod -L devmon 549 | 550 | # Add and start Devmon service 551 | ${sudo_cmd} systemctl enable devmon@devmon 552 | ${sudo_cmd} systemctl start devmon@devmon 553 | fi 554 | } 555 | 556 | #Clean Temp Files 557 | Clean_Temp_Files() { 558 | Show 0 "Clean..." 559 | ${sudo_cmd} rm -rf "$PREFIX${CASA_UNZIP_TEMP_FOLDER}" 560 | sync 561 | } 562 | 563 | #Install CasaOS 564 | Install_CasaOS() { 565 | Show 2 "Installing..." 566 | 567 | # Install Bin 568 | ${sudo_cmd} mv -f $PREFIX${CASA_UNZIP_TEMP_FOLDER}/${CASA_BIN} ${CASA_BIN_PATH} 569 | 570 | # Install Helper 571 | if [[ -d ${CASA_HELPER_PATH} ]]; then 572 | ${sudo_cmd} rm -rf ${CASA_HELPER_PATH}* 573 | fi 574 | ${sudo_cmd} cp -rf $PREFIX${CASA_UNZIP_TEMP_FOLDER}/shell/* ${CASA_HELPER_PATH} 575 | #Setting Executable Permissions 576 | ${sudo_cmd} chmod +x $PREFIX${CASA_HELPER_PATH}* 577 | 578 | # Install Conf 579 | if [[ ! -f $PREFIX${CASA_CONF_PATH} ]]; then 580 | if [[ -f $PREFIX${CASA_UNZIP_TEMP_FOLDER}/conf/conf.ini.sample ]]; then 581 | ${sudo_cmd} mv -f $PREFIX${CASA_UNZIP_TEMP_FOLDER}/conf/conf.ini.sample ${CASA_CONF_PATH} 582 | else 583 | ${sudo_cmd} mv -f $PREFIX${CASA_UNZIP_TEMP_FOLDER}/conf/conf.conf.sample ${CASA_CONF_PATH} 584 | fi 585 | 586 | fi 587 | sync 588 | 589 | if [[ ! -x "$(command -v ${CASA_BIN})" ]]; then 590 | Show 1 "Installation failed, please try again." 591 | exit 1 592 | else 593 | Show 0 "CasaOS Successfully installed." 594 | fi 595 | } 596 | 597 | #Generate Service File 598 | Generate_Service() { 599 | if [ -f ${CASA_SERVICE_PATH} ]; then 600 | Show 2 "Try stop CasaOS system service." 601 | # Stop before generation 602 | if [[ $(systemctl is-active ${CASA_BIN}) == "active" ]]; then 603 | ${sudo_cmd} systemctl stop ${CASA_BIN} 604 | fi 605 | fi 606 | Show 2 "Create system service for CasaOS." 607 | 608 | ${sudo_cmd} tee ${CASA_SERVICE_PATH} >/dev/null </dev/null || { 452 | ${sudo_cmd} useradd -M -u 300 ${USERNAME} 453 | ${sudo_cmd} usermod -L ${USERNAME} 454 | } 455 | 456 | # Add and start Devmon service 457 | GreyStart 458 | ${sudo_cmd} systemctl enable devmon@devmon 459 | ${sudo_cmd} systemctl start devmon@devmon 460 | ColorReset 461 | # ColorReset 462 | fi 463 | } 464 | 465 | # Download And Install CasaOS 466 | DownloadAndInstallCasaOS() { 467 | # Get the latest version of CasaOS 468 | if [[ ! -n "$version" ]]; then 469 | CASA_TAG="v$(${NET_GETTER} ${CASA_VERSION_URL})" 470 | elif [[ $version == "pre" ]]; then 471 | CASA_TAG="$(${NET_GETTER} ${CASA_RELEASE_API} | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g' | sed -n '1p')" 472 | else 473 | CASA_TAG="$version" 474 | fi 475 | 476 | # CASA_TAG="v0.3.6-alpha2" 477 | 478 | if [ -z "${BUILD_DIR}" ]; then 479 | ${sudo_cmd} rm -rf ${TMP_ROOT} 480 | mkdir -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory" 481 | TMP_DIR=$(mktemp -d -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory") 482 | 483 | pushd "${TMP_DIR}" 484 | 485 | for PACKAGE in "${CASA_PACKAGES[@]}"; do 486 | Show 2 "Downloading ${PACKAGE}..." 487 | GreyStart 488 | curl -sLO "${PACKAGE}" || Show 1 "Failed to download package" 489 | ColorReset 490 | done 491 | 492 | for PACKAGE_FILE in linux-*-casaos-*.tar.gz; do 493 | Show 2 "Extracting ${PACKAGE_FILE}..." 494 | GreyStart 495 | tar zxf "${PACKAGE_FILE}" || Show 1 "Failed to extract package" 496 | ColorReset 497 | done 498 | 499 | BUILD_DIR=$(realpath -e "${TMP_DIR}"/build || Show 1 "Failed to find build directory") 500 | 501 | popd 502 | fi 503 | 504 | for SERVICE in "${CASA_SERVICES[@]}"; do 505 | Show 2 "Stopping ${SERVICE}..." 506 | GreyStart 507 | ${sudo_cmd} systemctl stop "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 508 | ColorReset 509 | done 510 | 511 | MIGRATION_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/migration/script.d || Show 1 "Failed to find migration script directory") 512 | 513 | for MIGRATION_SCRIPT in "${MIGRATION_SCRIPT_DIR}"/*.sh; do 514 | Show 2 "Running ${MIGRATION_SCRIPT}..." 515 | GreyStart 516 | ${sudo_cmd} bash "${MIGRATION_SCRIPT}" || Show 1 "Failed to run migration script" 517 | ColorReset 518 | done 519 | 520 | Show 2 "Installing CasaOS..." 521 | SYSROOT_DIR=$(realpath -e "${BUILD_DIR}"/sysroot || Show 1 "Failed to find sysroot directory") 522 | 523 | # Generate manifest for uninstallation 524 | MANIFEST_FILE=${BUILD_DIR}/sysroot/var/lib/casaos/manifest 525 | ${sudo_cmd} touch "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 526 | 527 | GreyStart 528 | find "${SYSROOT_DIR}" -type f | ${sudo_cmd} cut -c ${#SYSROOT_DIR}- | ${sudo_cmd} cut -c 2- | ${sudo_cmd} tee "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 529 | 530 | ${sudo_cmd} cp -rf "${SYSROOT_DIR}"/* / || Show 1 "Failed to install CasaOS" 531 | ColorReset 532 | 533 | SETUP_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/setup/script.d || Show 1 "Failed to find setup script directory") 534 | 535 | for SETUP_SCRIPT in "${SETUP_SCRIPT_DIR}"/*.sh; do 536 | Show 2 "Running ${SETUP_SCRIPT}..." 537 | GreyStart 538 | ${sudo_cmd} bash "${SETUP_SCRIPT}" || Show 1 "Failed to run setup script" 539 | ColorReset 540 | done 541 | 542 | #Download Uninstall Script 543 | if [[ -f $PREFIX/tmp/casaos-uninstall ]]; then 544 | ${sudo_cmd} rm -rf $PREFIX/tmp/casaos-uninstall 545 | fi 546 | ${sudo_cmd} curl -fsSLk "$CASA_UNINSTALL_URL" >"$PREFIX/tmp/casaos-uninstall" 547 | ${sudo_cmd} cp -rf "$PREFIX/tmp/casaos-uninstall" $CASA_UNINSTALL_PATH 548 | if [[ $? -ne 0 ]]; then 549 | Show 1 "Download uninstall script failed, Please check if your internet connection is working and retry." 550 | exit 1 551 | fi 552 | ${sudo_cmd} chmod +x $CASA_UNINSTALL_PATH 553 | 554 | for SERVICE in "${CASA_SERVICES[@]}"; do 555 | Show 2 "Starting ${SERVICE}..." 556 | GreyStart 557 | ${sudo_cmd} systemctl start "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 558 | ColorReset 559 | done 560 | } 561 | 562 | Clean_Temp_Files() { 563 | Show 2 "Clean temporary files..." 564 | ${sudo_cmd} rm -rf "${TMP_DIR}" || Show 1 "Failed to clean temporary files" 565 | } 566 | 567 | Check_Service_status() { 568 | for SERVICE in "${CASA_SERVICES[@]}"; do 569 | Show 2 "Checking ${SERVICE}..." 570 | if [[ $(${sudo_cmd} systemctl is-active ${SERVICE}) == "active" ]]; then 571 | Show 0 "${SERVICE} is running." 572 | else 573 | Show 1 "${SERVICE} is not running, Please reinstall." 574 | exit 1 575 | fi 576 | done 577 | } 578 | 579 | # Get the physical NIC IP 580 | Get_IPs() { 581 | PORT=$(${sudo_cmd} cat ${CASA_CONF_PATH} | grep port | sed 's/port=//') 582 | ALL_NIC=$($sudo_cmd ls /sys/class/net/ | grep -v "$(ls /sys/devices/virtual/net/)") 583 | for NIC in ${ALL_NIC}; do 584 | IP=$($sudo_cmd ifconfig ${NIC} | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | tr -d "addr:") 585 | if [[ -n $IP ]]; then 586 | if [[ "$PORT" -eq "80" ]]; then 587 | echo -e "${GREEN_BULLET} http://$IP (${NIC})" 588 | else 589 | echo -e "${GREEN_BULLET} http://$IP:$PORT (${NIC})" 590 | fi 591 | fi 592 | done 593 | } 594 | 595 | # Show Welcome Banner 596 | Welcome_Banner() { 597 | echo -e "${GREEN_LINE}${aCOLOUR[1]}" 598 | echo -e " CasaOS ${Casa_Tag}${COLOUR_RESET} is running at${COLOUR_RESET}${GREEN_SEPARATOR}" 599 | echo -e "${GREEN_LINE}" 600 | Get_IPs 601 | echo -e " Open your browser and visit the above address." 602 | echo -e "${GREEN_LINE}" 603 | echo -e "" 604 | echo -e " ${aCOLOUR[2]}CasaOS Project : https://github.com/IceWhaleTech/CasaOS" 605 | echo -e " ${aCOLOUR[2]}CasaOS Team : https://github.com/IceWhaleTech/CasaOS#maintainers" 606 | echo -e " ${aCOLOUR[2]}CasaOS Discord : https://discord.gg/knqAbbBbeX" 607 | echo -e " ${aCOLOUR[2]}Website : https://www.casaos.io" 608 | echo -e " ${aCOLOUR[2]}Online Demo : http://demo.casaos.io" 609 | echo -e "" 610 | echo -e " ${COLOUR_RESET}${aCOLOUR[1]}Uninstall ${COLOUR_RESET}: casaos-uninstall" 611 | echo -e "${COLOUR_RESET}" 612 | } 613 | 614 | ############################################################################### 615 | # Main # 616 | ############################################################################### 617 | 618 | #Usage 619 | usage() { 620 | cat <<-EOF 621 | Usage: install.sh [options] 622 | Valid options are: 623 | -v Specify version to install For example: install.sh -v v0.3.6 or install.sh (Only versions after 0.3.6 can be installed) 624 | -p Specify build directory (Local install) 625 | -h Show this help message and exit 626 | EOF 627 | exit $1 628 | } 629 | 630 | while getopts ":v:p:h" arg; do 631 | case "$arg" in 632 | v) 633 | version=$OPTARG 634 | ;; 635 | p) 636 | BUILD_DIR=$OPTARG 637 | ;; 638 | h) 639 | usage 0 640 | ;; 641 | esac 642 | done 643 | 644 | # Step 1:Check ARCH 645 | Check_Arch 646 | 647 | # Step 2: Check OS 648 | Check_OS 649 | 650 | # Step 3: Check Distribution 651 | Check_Distribution 652 | 653 | # Step 4: Check System Required 654 | Check_Memory 655 | Check_Disk 656 | 657 | # Step 5: Install Depends 658 | Update_Package_Resource 659 | Install_Depends 660 | Check_Dependency_Installation 661 | 662 | # Step 6: Check And Install Docker 663 | Check_Docker_Install 664 | 665 | # Step 7: Configuration Addon 666 | Configuration_Addons 667 | 668 | # Step 8: Download And Install CasaOS 669 | DownloadAndInstallCasaOS 670 | 671 | # Step 9: Check Service Status 672 | Check_Service_status 673 | 674 | # Step 10: Show Welcome Banner 675 | #Clear_Term 676 | Welcome_Banner 677 | -------------------------------------------------------------------------------- /get.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # 3 | # CasaOS Installer Script 4 | # 5 | # GitHub: https://github.com/IceWhaleTech/CasaOS 6 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 7 | # Requires: bash, mv, rm, tr, grep, sed, curl/wget, tar, smartmontools, parted, ntfs-3g, net-tools 8 | # 9 | # This script installs CasaOS to your system. 10 | # Usage: 11 | # 12 | # $ curl -fsSL https://get.casaos.io | sudo bash 13 | # or 14 | # $ wget -qO- https://get.casaos.io | sudo bash 15 | # 16 | # In automated environments, you may want to run as root. 17 | # If using curl, we recommend using the -fsSL flags. 18 | # 19 | # This only work on Linux systems. Please 20 | # open an issue if you notice any bugs. 21 | # 22 | clear 23 | echo -e "\e[0m\c" 24 | 25 | # shellcheck disable=SC2016 26 | echo ' 27 | _____ ____ _____ 28 | / ____| / __ \ / ____| 29 | | | __ _ ___ __ _| | | | (___ 30 | | | / _` / __|/ _` | | | |\___ \ 31 | | |___| (_| \__ \ (_| | |__| |____) | 32 | \_____\__,_|___/\__,_|\____/|_____/ 33 | 34 | --- Made by IceWhale with YOU --- 35 | ' 36 | export PATH=/usr/sbin:$PATH 37 | set -e 38 | 39 | ############################################################################### 40 | # GOLBALS # 41 | ############################################################################### 42 | 43 | ((EUID)) && sudo_cmd="sudo" 44 | 45 | # shellcheck source=/dev/null 46 | source /etc/os-release 47 | 48 | readonly TITLE="CasaOS Installer" 49 | 50 | # SYSTEM REQUIREMENTS 51 | readonly MINIMUM_DISK_SIZE_GB="5" 52 | readonly MINIMUM_MEMORY="400" 53 | readonly MINIMUM_DOCKER_VERSION="20" 54 | readonly CASA_DEPANDS_PACKAGE=('curl' 'smartmontools' 'parted' 'ntfs-3g' 'net-tools' 'whiptail' 'udevil' 'samba' 'cifs-utils') 55 | readonly CASA_DEPANDS_COMMAND=('curl' 'smartctl' 'parted' 'ntfs-3g' 'netstat' 'whiptail' 'udevil' 'samba' 'mount.cifs') 56 | 57 | # SYSTEM INFO 58 | PHYSICAL_MEMORY=$(LC_ALL=C free -m | awk '/Mem:/ { print $2 }') 59 | readonly PHYSICAL_MEMORY 60 | 61 | FREE_DISK_BYTES=$(LC_ALL=C df -P / | tail -n 1 | awk '{print $4}') 62 | readonly FREE_DISK_BYTES 63 | 64 | readonly FREE_DISK_GB=$((FREE_DISK_BYTES / 1024 / 1024)) 65 | 66 | LSB_DIST=$( ( [ -n "${ID_LIKE}" ] && echo "${ID_LIKE}" ) || ( [ -n "${ID}" ] && echo "${ID}" ) ) 67 | readonly LSB_DIST 68 | 69 | UNAME_M="$(uname -m)" 70 | readonly UNAME_M 71 | 72 | UNAME_U="$(uname -s)" 73 | readonly UNAME_U 74 | 75 | readonly CASA_CONF_PATH=/etc/casaos/gateway.ini 76 | readonly CASA_UNINSTALL_URL="https://raw.githubusercontent.com/IceWhaleTech/get/main/uninstall.sh" 77 | readonly CASA_UNINSTALL_PATH=/usr/bin/casaos-uninstall 78 | 79 | # REQUIREMENTS CONF PATH 80 | # Udevil 81 | readonly UDEVIL_CONF_PATH=/etc/udevil/udevil.conf 82 | 83 | # COLORS 84 | readonly COLOUR_RESET='\e[0m' 85 | readonly aCOLOUR=( 86 | '\e[38;5;154m' # green | Lines, bullets and separators 87 | '\e[1m' # Bold white | Main descriptions 88 | '\e[90m' # Grey | Credits 89 | '\e[91m' # Red | Update notifications Alert 90 | '\e[33m' # Yellow | Emphasis 91 | ) 92 | 93 | readonly GREEN_LINE=" ${aCOLOUR[0]}─────────────────────────────────────────────────────$COLOUR_RESET" 94 | readonly GREEN_BULLET=" ${aCOLOUR[0]}-$COLOUR_RESET" 95 | readonly GREEN_SEPARATOR="${aCOLOUR[0]}:$COLOUR_RESET" 96 | 97 | # CASAOS VARIABLES 98 | TARGET_ARCH="" 99 | TMP_ROOT=/tmp/casaos-installer 100 | 101 | trap 'onCtrlC' INT 102 | onCtrlC() { 103 | echo -e "${COLOUR_RESET}" 104 | exit 1 105 | } 106 | 107 | ############################################################################### 108 | # Helpers # 109 | ############################################################################### 110 | 111 | ####################################### 112 | # Custom printing function 113 | # Globals: 114 | # None 115 | # Arguments: 116 | # $1 0:OK 1:FAILED 2:INFO 3:NOTICE 117 | # message 118 | # Returns: 119 | # None 120 | ####################################### 121 | 122 | Show() { 123 | # OK 124 | if (($1 == 0)); then 125 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 126 | # FAILED 127 | elif (($1 == 1)); then 128 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 129 | exit 1 130 | # INFO 131 | elif (($1 == 2)); then 132 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 133 | # NOTICE 134 | elif (($1 == 3)); then 135 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 136 | fi 137 | } 138 | 139 | Warn() { 140 | echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" 141 | } 142 | 143 | GreyStart() { 144 | echo -e "${aCOLOUR[2]}\c" 145 | } 146 | 147 | ColorReset() { 148 | echo -e "$COLOUR_RESET\c" 149 | } 150 | 151 | # Clear Terminal 152 | Clear_Term() { 153 | 154 | # Without an input terminal, there is no point in doing this. 155 | [[ -t 0 ]] || return 156 | 157 | # Printing terminal height - 1 newlines seems to be the fastest method that is compatible with all terminal types. 158 | lines=$(tput lines) i newlines 159 | local lines 160 | 161 | for ((i = 1; i < ${lines% *}; i++)); do newlines+='\n'; done 162 | echo -ne "\e[0m$newlines\e[H" 163 | 164 | } 165 | 166 | # Check file exists 167 | exist_file() { 168 | if [ -e "$1" ]; then 169 | return 1 170 | else 171 | return 2 172 | fi 173 | } 174 | 175 | ############################################################################### 176 | # FUNCTIONS # 177 | ############################################################################### 178 | 179 | # 1 Check Arch 180 | Check_Arch() { 181 | case $UNAME_M in 182 | *aarch64*) 183 | TARGET_ARCH="arm64" 184 | ;; 185 | *riscv64*) 186 | TARGET_ARCH="riscv64" 187 | ;; 188 | *64*) 189 | TARGET_ARCH="amd64" 190 | ;; 191 | *armv7*) 192 | TARGET_ARCH="arm-7" 193 | ;; 194 | *) 195 | Show 1 "Aborted, unsupported or unknown architecture: $UNAME_M" 196 | exit 1 197 | ;; 198 | esac 199 | Show 0 "Your hardware architecture is : $UNAME_M" 200 | CASA_PACKAGES=( 201 | "https://github.com/IceWhaleTech/CasaOS-Gateway/releases/download/v0.3.6/linux-${TARGET_ARCH}-casaos-gateway-v0.3.6.tar.gz" 202 | "https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/v0.3.7/linux-${TARGET_ARCH}-casaos-user-service-v0.3.7.tar.gz" 203 | "https://github.com/IceWhaleTech/CasaOS-LocalStorage/releases/download/v0.3.7-1/linux-${TARGET_ARCH}-casaos-local-storage-v0.3.7-1.tar.gz" 204 | "https://github.com/IceWhaleTech/CasaOS/releases/download/v0.3.7/linux-${TARGET_ARCH}-casaos-v0.3.7.tar.gz" 205 | "https://github.com/IceWhaleTech/CasaOS-UI/releases/download/v0.3.7/linux-all-casaos-v0.3.7.tar.gz" 206 | ) 207 | } 208 | 209 | # PACKAGE LIST OF CASAOS (make sure the services are in the right order) 210 | CASA_SERVICES=( 211 | "casaos-gateway.service" 212 | "casaos-user-service.service" 213 | "casaos-local-storage.service" 214 | "casaos.service" # must be the last one so update from UI can work 215 | ) 216 | 217 | # 2 Check Distribution 218 | Check_Distribution() { 219 | sType=0 220 | notice="" 221 | case $LSB_DIST in 222 | *debian*) 223 | ;; 224 | *ubuntu*) 225 | ;; 226 | *raspbian*) 227 | ;; 228 | *openwrt*) 229 | Show 1 "Aborted, OpenWrt cannot be installed using this script, please visit ${CASA_OPENWRT_DOCS}." 230 | exit 1 231 | ;; 232 | *alpine*) 233 | Show 1 "Aborted, Alpine installation is not yet supported." 234 | exit 1 235 | ;; 236 | *trisquel*) 237 | ;; 238 | *) 239 | sType=1 240 | notice="We have not tested it on this system and it may fail to install." 241 | ;; 242 | esac 243 | Show $sType "Your Linux Distribution is : $LSB_DIST $notice" 244 | if [[ $sType == 1 ]]; then 245 | if (whiptail --title "${TITLE}" --yesno --defaultno "Your Linux Distribution is : $LSB_DIST $notice. Continue installation?" 10 60); then 246 | Show 0 "Distribution check has been ignored." 247 | else 248 | Show 1 "Already exited the installation." 249 | exit 1 250 | fi 251 | fi 252 | } 253 | 254 | # 3 Check OS 255 | Check_OS() { 256 | if [[ $UNAME_U == *Linux* ]]; then 257 | Show 0 "Your System is : $UNAME_U" 258 | else 259 | Show 1 "This script is only for Linux." 260 | exit 1 261 | fi 262 | } 263 | 264 | # 4 Check Memory 265 | Check_Memory() { 266 | if [[ "${PHYSICAL_MEMORY}" -lt "${MINIMUM_MEMORY}" ]]; then 267 | Show 1 "requires atleast 1GB physical memory." 268 | exit 1 269 | fi 270 | Show 0 "Memory capacity check passed." 271 | } 272 | 273 | # 5 Check Disk 274 | Check_Disk() { 275 | if [[ "${FREE_DISK_GB}" -lt "${MINIMUM_DISK_SIZE_GB}" ]]; then 276 | if (whiptail --title "${TITLE}" --yesno --defaultno "Recommended free disk space is greater than ${MINIMUM_DISK_SIZE_GB}GB, Current free disk space is ${FREE_DISK_GB}GB.Continue installation?" 10 60); then 277 | Show 0 "Disk capacity check has been ignored." 278 | else 279 | Show 1 "Already exited the installation." 280 | exit 1 281 | fi 282 | else 283 | Show 0 "Disk capacity check passed." 284 | fi 285 | } 286 | 287 | # Check Port Use 288 | Check_Port() { 289 | TCPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l) 290 | UDPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "udp" && $NF == "0.0.0.0:*" {print $0}' | wc -l) 291 | ((Listeningnum = TCPListeningnum + UDPListeningnum)) 292 | if [[ $Listeningnum == 0 ]]; then 293 | echo "0" 294 | else 295 | echo "1" 296 | fi 297 | } 298 | 299 | # Get an available port 300 | Get_Port() { 301 | CurrentPort=$(${sudo_cmd} cat ${CASA_CONF_PATH} | grep HttpPort | awk '{print $3}') 302 | if [[ $CurrentPort == "$Port" ]]; then 303 | for PORT in {80..65536}; do 304 | if [[ $(Check_Port "$PORT") == 0 ]]; then 305 | Port=$PORT 306 | break 307 | fi 308 | done 309 | else 310 | Port=$CurrentPort 311 | fi 312 | } 313 | 314 | # Update package 315 | 316 | Update_Package_Resource() { 317 | GreyStart 318 | if [ -x "$(command -v apk)" ]; then 319 | ${sudo_cmd} apk update 320 | elif [ -x "$(command -v apt-get)" ]; then 321 | ${sudo_cmd} apt-get update 322 | elif [ -x "$(command -v dnf)" ]; then 323 | ${sudo_cmd} dnf check-update 324 | elif [ -x "$(command -v zypper)" ]; then 325 | ${sudo_cmd} zypper update 326 | elif [ -x "$(command -v yum)" ]; then 327 | ${sudo_cmd} yum update 328 | fi 329 | ColorReset 330 | } 331 | 332 | # Install depends package 333 | Install_Depends() { 334 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 335 | cmd=${CASA_DEPANDS_COMMAND[i]} 336 | if [[ ! -x $(${sudo_cmd} which "$cmd") ]]; then 337 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 338 | Show 2 "Install the necessary dependencies: \e[33m$packagesNeeded \e[0m" 339 | GreyStart 340 | if [ -x "$(command -v apk)" ]; then 341 | ${sudo_cmd} apk add --no-cache "$packagesNeeded" 342 | elif [ -x "$(command -v apt-get)" ]; then 343 | ${sudo_cmd} apt-get -y -q install "$packagesNeeded" --no-upgrade 344 | elif [ -x "$(command -v dnf)" ]; then 345 | ${sudo_cmd} dnf install "$packagesNeeded" 346 | elif [ -x "$(command -v zypper)" ]; then 347 | ${sudo_cmd} zypper install "$packagesNeeded" 348 | elif [ -x "$(command -v yum)" ]; then 349 | ${sudo_cmd} yum install "$packagesNeeded" 350 | elif [ -x "$(command -v pacman)" ]; then 351 | ${sudo_cmd} pacman -S "$packagesNeeded" 352 | elif [ -x "$(command -v paru)" ]; then 353 | ${sudo_cmd} paru -S "$packagesNeeded" 354 | else 355 | Show 1 "Package manager not found. You must manually install: \e[33m$packagesNeeded \e[0m" 356 | fi 357 | ColorReset 358 | fi 359 | done 360 | } 361 | 362 | Check_Dependency_Installation() { 363 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 364 | cmd=${CASA_DEPANDS_COMMAND[i]} 365 | if [[ ! -x $(${sudo_cmd} which "$cmd") ]]; then 366 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 367 | Show 1 "Dependency \e[33m$packagesNeeded \e[0m installation failed, please try again manually!" 368 | exit 1 369 | fi 370 | done 371 | } 372 | 373 | # Check Docker running 374 | Check_Docker_Running() { 375 | for ((i = 1; i <= 3; i++)); do 376 | sleep 3 377 | if [[ ! $(${sudo_cmd} systemctl is-active docker) == "active" ]]; then 378 | Show 1 "Docker is not running, try to start" 379 | ${sudo_cmd} systemctl start docker 380 | else 381 | break 382 | fi 383 | done 384 | } 385 | 386 | #Check Docker Installed and version 387 | Check_Docker_Install() { 388 | if [[ -x "$(command -v docker)" ]]; then 389 | Docker_Version=$(${sudo_cmd} docker version --format '{{.Server.Version}}') 390 | if [[ $? -ne 0 ]]; then 391 | Install_Docker 392 | elif [[ ${Docker_Version:0:2} -lt "${MINIMUM_DOCKER_VERSION}" ]]; then 393 | Show 1 "Recommended minimum Docker version is \e[33m${MINIMUM_DOCKER_VERSION}.xx.xx\e[0m,\Current Docker version is \e[33m${Docker_Version}\e[0m,\nPlease uninstall current Docker and rerun the CasaOS installation script." 394 | exit 1 395 | else 396 | Show 0 "Current Docker version is ${Docker_Version}." 397 | fi 398 | else 399 | Install_Docker 400 | fi 401 | } 402 | 403 | # Check Docker installed 404 | Check_Docker_Install_Final() { 405 | if [[ -x "$(command -v docker)" ]]; then 406 | Docker_Version=$(${sudo_cmd} docker version --format '{{.Server.Version}}') 407 | if [[ $? -ne 0 ]]; then 408 | Install_Docker 409 | elif [[ ${Docker_Version:0:2} -lt "${MINIMUM_DOCKER_VERSION}" ]]; then 410 | Show 1 "Recommended minimum Docker version is \e[33m${MINIMUM_DOCKER_VERSION}.xx.xx\e[0m,\Current Docker version is \e[33m${Docker_Version}\e[0m,\nPlease uninstall current Docker and rerun the CasaOS installation script." 411 | exit 1 412 | else 413 | Show 0 "Current Docker version is ${Docker_Version}." 414 | Check_Docker_Running 415 | fi 416 | else 417 | Show 1 "Installation failed, please run 'curl -fsSL https://get.docker.com | bash' and rerun the CasaOS installation script." 418 | exit 1 419 | fi 420 | } 421 | 422 | #Install Docker 423 | Install_Docker() { 424 | Show 2 "Install the necessary dependencies: \e[33mDocker \e[0m" 425 | GreyStart 426 | curl -fsSL https://get.docker.com | bash 427 | ColorReset 428 | if [[ $? -ne 0 ]]; then 429 | Show 1 "Installation failed, please try again." 430 | exit 1 431 | else 432 | Check_Docker_Install_Final 433 | fi 434 | } 435 | 436 | #Configuration Addons 437 | Configuration_Addons() { 438 | Show 2 "Configuration CasaOS Addons" 439 | #Remove old udev rules 440 | if [[ -f "${PREFIX}/etc/udev/rules.d/11-usb-mount.rules" ]]; then 441 | ${sudo_cmd} rm -rf "${PREFIX}/etc/udev/rules.d/11-usb-mount.rules" 442 | fi 443 | 444 | if [[ -f "${PREFIX}/etc/systemd/system/usb-mount@.service" ]]; then 445 | ${sudo_cmd} rm -rf "${PREFIX}/etc/systemd/system/usb-mount@.service" 446 | fi 447 | 448 | #Udevil 449 | if [[ -f $PREFIX${UDEVIL_CONF_PATH} ]]; then 450 | 451 | # GreyStart 452 | # Add a devmon user 453 | USERNAME=devmon 454 | id ${USERNAME} &>/dev/null || { 455 | ${sudo_cmd} useradd -M -u 300 ${USERNAME} 456 | ${sudo_cmd} usermod -L ${USERNAME} 457 | } 458 | 459 | # Add and start Devmon service 460 | GreyStart 461 | ${sudo_cmd} systemctl enable devmon@devmon 462 | ${sudo_cmd} systemctl start devmon@devmon 463 | ColorReset 464 | # ColorReset 465 | fi 466 | } 467 | 468 | # Download And Install CasaOS 469 | DownloadAndInstallCasaOS() { 470 | if [ -z "${BUILD_DIR}" ]; then 471 | ${sudo_cmd} rm -rf ${TMP_ROOT} 472 | mkdir -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory" 473 | TMP_DIR=$(mktemp -d -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory") 474 | 475 | pushd "${TMP_DIR}" 476 | 477 | for PACKAGE in "${CASA_PACKAGES[@]}"; do 478 | Show 2 "Downloading ${PACKAGE}..." 479 | GreyStart 480 | curl -sLO "${PACKAGE}" || Show 1 "Failed to download package" 481 | ColorReset 482 | done 483 | 484 | for PACKAGE_FILE in linux-*-casaos-*.tar.gz; do 485 | Show 2 "Extracting ${PACKAGE_FILE}..." 486 | GreyStart 487 | tar zxf "${PACKAGE_FILE}" || Show 1 "Failed to extract package" 488 | ColorReset 489 | done 490 | 491 | BUILD_DIR=$(realpath -e "${TMP_DIR}"/build || Show 1 "Failed to find build directory") 492 | 493 | popd 494 | fi 495 | 496 | for SERVICE in "${CASA_SERVICES[@]}"; do 497 | Show 2 "Stopping ${SERVICE}..." 498 | GreyStart 499 | ${sudo_cmd} systemctl stop "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 500 | ColorReset 501 | done 502 | 503 | MIGRATION_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/migration/script.d || Show 1 "Failed to find migration script directory") 504 | 505 | for MIGRATION_SCRIPT in "${MIGRATION_SCRIPT_DIR}"/*.sh; do 506 | Show 2 "Running ${MIGRATION_SCRIPT}..." 507 | GreyStart 508 | ${sudo_cmd} bash "${MIGRATION_SCRIPT}" || Show 1 "Failed to run migration script" 509 | ColorReset 510 | done 511 | 512 | Show 2 "Installing CasaOS..." 513 | SYSROOT_DIR=$(realpath -e "${BUILD_DIR}"/sysroot || Show 1 "Failed to find sysroot directory") 514 | 515 | # Generate manifest for uninstallation 516 | MANIFEST_FILE=${BUILD_DIR}/sysroot/var/lib/casaos/manifest 517 | ${sudo_cmd} touch "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 518 | 519 | GreyStart 520 | find "${SYSROOT_DIR}" -type f | ${sudo_cmd} cut -c ${#SYSROOT_DIR}- | ${sudo_cmd} cut -c 2- | ${sudo_cmd} tee "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 521 | 522 | ${sudo_cmd} cp -rf "${SYSROOT_DIR}"/* / || Show 1 "Failed to install CasaOS" 523 | ColorReset 524 | 525 | SETUP_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/setup/script.d || Show 1 "Failed to find setup script directory") 526 | 527 | for SETUP_SCRIPT in "${SETUP_SCRIPT_DIR}"/*.sh; do 528 | Show 2 "Running ${SETUP_SCRIPT}..." 529 | GreyStart 530 | ${sudo_cmd} bash "${SETUP_SCRIPT}" || Show 1 "Failed to run setup script" 531 | ColorReset 532 | done 533 | 534 | #Download Uninstall Script 535 | if [[ -f $PREFIX/tmp/casaos-uninstall ]]; then 536 | ${sudo_cmd} rm -rf "$PREFIX/tmp/casaos-uninstall" 537 | fi 538 | ${sudo_cmd} curl -fsSLk "$CASA_UNINSTALL_URL" >"$PREFIX/tmp/casaos-uninstall" 539 | ${sudo_cmd} cp -rf "$PREFIX/tmp/casaos-uninstall" $CASA_UNINSTALL_PATH || { 540 | Show 1 "Download uninstall script failed, Please check if your internet connection is working and retry." 541 | exit 1 542 | } 543 | 544 | ${sudo_cmd} chmod +x $CASA_UNINSTALL_PATH 545 | 546 | for SERVICE in "${CASA_SERVICES[@]}"; do 547 | Show 2 "Starting ${SERVICE}..." 548 | GreyStart 549 | ${sudo_cmd} systemctl start "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 550 | ColorReset 551 | done 552 | } 553 | 554 | Clean_Temp_Files() { 555 | Show 2 "Clean temporary files..." 556 | ${sudo_cmd} rm -rf "${TMP_DIR}" || Show 1 "Failed to clean temporary files" 557 | } 558 | 559 | Check_Service_status() { 560 | for SERVICE in "${CASA_SERVICES[@]}"; do 561 | Show 2 "Checking ${SERVICE}..." 562 | if [[ $(${sudo_cmd} systemctl is-active "${SERVICE}") == "active" ]]; then 563 | Show 0 "${SERVICE} is running." 564 | else 565 | Show 1 "${SERVICE} is not running, Please reinstall." 566 | exit 1 567 | fi 568 | done 569 | } 570 | 571 | # Get the physical NIC IP 572 | Get_IPs() { 573 | PORT=$(${sudo_cmd} cat ${CASA_CONF_PATH} | grep port | sed 's/port=//') 574 | ALL_NIC=$($sudo_cmd ls /sys/class/net/ | grep -v "$(ls /sys/devices/virtual/net/)") 575 | for NIC in ${ALL_NIC}; do 576 | IP=$($sudo_cmd ifconfig "${NIC}" | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed -e 's/addr://g') 577 | if [[ -n $IP ]]; then 578 | if [[ "$PORT" -eq "80" ]]; then 579 | echo -e "${GREEN_BULLET} http://$IP (${NIC})" 580 | else 581 | echo -e "${GREEN_BULLET} http://$IP:$PORT (${NIC})" 582 | fi 583 | fi 584 | done 585 | } 586 | 587 | # Show Welcome Banner 588 | Welcome_Banner() { 589 | CASA_TAG=$(casaos -v) 590 | 591 | echo -e "${GREEN_LINE}${aCOLOUR[1]}" 592 | echo -e " CasaOS ${CASA_TAG}${COLOUR_RESET} is running at${COLOUR_RESET}${GREEN_SEPARATOR}" 593 | echo -e "${GREEN_LINE}" 594 | Get_IPs 595 | echo -e " Open your browser and visit the above address." 596 | echo -e "${GREEN_LINE}" 597 | echo -e "" 598 | echo -e " ${aCOLOUR[2]}CasaOS Project : https://github.com/IceWhaleTech/CasaOS" 599 | echo -e " ${aCOLOUR[2]}CasaOS Team : https://github.com/IceWhaleTech/CasaOS#maintainers" 600 | echo -e " ${aCOLOUR[2]}CasaOS Discord : https://discord.gg/knqAbbBbeX" 601 | echo -e " ${aCOLOUR[2]}Website : https://www.casaos.io" 602 | echo -e " ${aCOLOUR[2]}Online Demo : http://demo.casaos.io" 603 | echo -e "" 604 | echo -e " ${COLOUR_RESET}${aCOLOUR[1]}Uninstall ${COLOUR_RESET}: casaos-uninstall" 605 | echo -e "${COLOUR_RESET}" 606 | } 607 | 608 | ############################################################################### 609 | # Main # 610 | ############################################################################### 611 | 612 | #Usage 613 | usage() { 614 | cat <<-EOF 615 | Usage: install.sh [options] 616 | Valid options are: 617 | -p Specify build directory (Local install) 618 | -h Show this help message and exit 619 | EOF 620 | exit "$1" 621 | } 622 | 623 | while getopts ":p:h" arg; do 624 | case "$arg" in 625 | p) 626 | BUILD_DIR=$OPTARG 627 | ;; 628 | h) 629 | usage 0 630 | ;; 631 | *) 632 | usage 1 633 | ;; 634 | esac 635 | done 636 | 637 | # Step 1:Check ARCH 638 | Check_Arch 639 | 640 | # Step 2: Check OS 641 | Check_OS 642 | 643 | # Step 3: Check Distribution 644 | Check_Distribution 645 | 646 | # Step 4: Check System Required 647 | Check_Memory 648 | Check_Disk 649 | 650 | # Step 5: Install Depends 651 | Update_Package_Resource 652 | Install_Depends 653 | Check_Dependency_Installation 654 | 655 | # Step 6: Check And Install Docker 656 | Check_Docker_Install 657 | 658 | # Step 7: Configuration Addon 659 | Configuration_Addons 660 | 661 | # Step 8: Download And Install CasaOS 662 | DownloadAndInstallCasaOS 663 | 664 | # Step 9: Check Service Status 665 | Check_Service_status 666 | 667 | # Step 10: Show Welcome Banner 668 | #Clear_Term 669 | Welcome_Banner 670 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # 3 | # CasaOS Installer Script 4 | # 5 | # GitHub: https://github.com/IceWhaleTech/CasaOS 6 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 7 | # Requires: bash, mv, rm, tr, grep, sed, curl/wget, tar, smartmontools, parted, ntfs-3g, net-tools 8 | # 9 | # This script installs CasaOS to your system. 10 | # Usage: 11 | # 12 | # $ wget -qO- https://get.casaos.io/ | bash 13 | # or 14 | # $ curl -fsSL https://get.casaos.io/ | bash 15 | # 16 | # In automated environments, you may want to run as root. 17 | # If using curl, we recommend using the -fsSL flags. 18 | # 19 | # This only work on Linux systems. Please 20 | # open an issue if you notice any bugs. 21 | # 22 | clear 23 | echo -e "\e[0m\c" 24 | 25 | # shellcheck disable=SC2016 26 | echo ' 27 | _____ ____ _____ 28 | / ____| / __ \ / ____| 29 | | | __ _ ___ __ _| | | | (___ 30 | | | / _` / __|/ _` | | | |\___ \ 31 | | |___| (_| \__ \ (_| | |__| |____) | 32 | \_____\__,_|___/\__,_|\____/|_____/ 33 | 34 | --- Made by IceWhale with YOU --- 35 | ' 36 | export PATH=/usr/sbin:$PATH 37 | export DEBIAN_FRONTEND=noninteractive 38 | 39 | set -e 40 | 41 | ############################################################################### 42 | # GOLBALS # 43 | ############################################################################### 44 | 45 | ((EUID)) && sudo_cmd="sudo" 46 | 47 | # shellcheck source=/dev/null 48 | source /etc/os-release 49 | 50 | # SYSTEM REQUIREMENTS 51 | readonly MINIMUM_DISK_SIZE_GB="5" 52 | readonly MINIMUM_MEMORY="400" 53 | readonly MINIMUM_DOCER_VERSION="20" 54 | readonly CASA_DEPANDS_PACKAGE=('curl' 'smartmontools' 'parted' 'ntfs-3g' 'net-tools' 'udevil' 'samba' 'cifs-utils') 55 | readonly CASA_DEPANDS_COMMAND=('curl' 'smartctl' 'parted' 'ntfs-3g' 'netstat' 'udevil' 'samba' 'mount.cifs') 56 | 57 | # SYSTEM INFO 58 | PHYSICAL_MEMORY=$(LC_ALL=C free -m | awk '/Mem:/ { print $2 }') 59 | readonly PHYSICAL_MEMORY 60 | 61 | FREE_DISK_BYTES=$(LC_ALL=C df -P / | tail -n 1 | awk '{print $4}') 62 | readonly FREE_DISK_BYTES 63 | 64 | readonly FREE_DISK_GB=$((FREE_DISK_BYTES / 1024 / 1024)) 65 | 66 | LSB_DIST=$( ([ -n "${ID_LIKE}" ] && echo "${ID_LIKE}") || ([ -n "${ID}" ] && echo "${ID}")) 67 | readonly LSB_DIST 68 | 69 | UNAME_M="$(uname -m)" 70 | readonly UNAME_M 71 | 72 | UNAME_U="$(uname -s)" 73 | readonly UNAME_U 74 | 75 | readonly CASA_CONF_PATH=/etc/casaos/gateway.ini 76 | readonly CASA_UNINSTALL_URL="https://get.casaos.io/uninstall/v0.4.0" 77 | readonly CASA_UNINSTALL_PATH=/usr/bin/casaos-uninstall 78 | 79 | # REQUIREMENTS CONF PATH 80 | # Udevil 81 | readonly UDEVIL_CONF_PATH=/etc/udevil/udevil.conf 82 | 83 | # COLORS 84 | readonly COLOUR_RESET='\e[0m' 85 | readonly aCOLOUR=( 86 | '\e[38;5;154m' # green | Lines, bullets and separators 87 | '\e[1m' # Bold white | Main descriptions 88 | '\e[90m' # Grey | Credits 89 | '\e[91m' # Red | Update notifications Alert 90 | '\e[33m' # Yellow | Emphasis 91 | ) 92 | 93 | readonly GREEN_LINE=" ${aCOLOUR[0]}─────────────────────────────────────────────────────$COLOUR_RESET" 94 | readonly GREEN_BULLET=" ${aCOLOUR[0]}-$COLOUR_RESET" 95 | readonly GREEN_SEPARATOR="${aCOLOUR[0]}:$COLOUR_RESET" 96 | 97 | # CASAOS VARIABLES 98 | TARGET_ARCH="" 99 | TMP_ROOT=/tmp/casaos-installer 100 | REGION="UNKNOWN" 101 | CASA_DOWNLOAD_DOMAIN="https://github.com/" 102 | 103 | trap 'onCtrlC' INT 104 | onCtrlC() { 105 | echo -e "${COLOUR_RESET}" 106 | exit 1 107 | } 108 | 109 | ############################################################################### 110 | # Helpers # 111 | ############################################################################### 112 | 113 | ####################################### 114 | # Custom printing function 115 | # Globals: 116 | # None 117 | # Arguments: 118 | # $1 0:OK 1:FAILED 2:INFO 3:NOTICE 119 | # message 120 | # Returns: 121 | # None 122 | ####################################### 123 | 124 | Show() { 125 | # OK 126 | if (($1 == 0)); then 127 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 128 | # FAILED 129 | elif (($1 == 1)); then 130 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 131 | exit 1 132 | # INFO 133 | elif (($1 == 2)); then 134 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 135 | # NOTICE 136 | elif (($1 == 3)); then 137 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 138 | fi 139 | } 140 | 141 | Warn() { 142 | echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" 143 | } 144 | 145 | GreyStart() { 146 | echo -e "${aCOLOUR[2]}\c" 147 | } 148 | 149 | ColorReset() { 150 | echo -e "$COLOUR_RESET\c" 151 | } 152 | 153 | # Clear Terminal 154 | Clear_Term() { 155 | 156 | # Without an input terminal, there is no point in doing this. 157 | [[ -t 0 ]] || return 158 | 159 | # Printing terminal height - 1 newlines seems to be the fastest method that is compatible with all terminal types. 160 | lines=$(tput lines) i newlines 161 | local lines 162 | 163 | for ((i = 1; i < ${lines% *}; i++)); do newlines+='\n'; done 164 | echo -ne "\e[0m$newlines\e[H" 165 | 166 | } 167 | 168 | # Check file exists 169 | exist_file() { 170 | if [ -e "$1" ]; then 171 | return 1 172 | else 173 | return 2 174 | fi 175 | } 176 | 177 | ############################################################################### 178 | # FUNCTIONS # 179 | ############################################################################### 180 | 181 | 182 | 183 | # 0 Get download url domain 184 | # To solve the problem that Chinese users cannot access github. 185 | Get_Download_Url_Domain() { 186 | # Use ipconfig.io/country and https://ifconfig.io/country_code to get the country code 187 | REGION=$(${sudo_cmd} curl --connect-timeout 2 -s ipconfig.io/country || echo "") 188 | if [ "${REGION}" = "" ]; then 189 | REGION=$(${sudo_cmd} curl --connect-timeout 2 -s https://ifconfig.io/country_code || echo "") 190 | fi 191 | if [[ "${REGION}" = "China" ]] || [[ "${REGION}" = "CN" ]]; then 192 | CASA_DOWNLOAD_DOMAIN="https://casaos.oss-cn-shanghai.aliyuncs.com/" 193 | fi 194 | } 195 | 196 | # 1 Check Arch 197 | Check_Arch() { 198 | case $UNAME_M in 199 | *aarch64*) 200 | TARGET_ARCH="arm64" 201 | ;; 202 | *riscv64*) 203 | TARGET_ARCH="riscv64" 204 | ;; 205 | *64*) 206 | TARGET_ARCH="amd64" 207 | ;; 208 | *armv7*) 209 | TARGET_ARCH="arm-7" 210 | ;; 211 | *) 212 | Show 1 "Aborted, unsupported or unknown architecture: $UNAME_M" 213 | exit 1 214 | ;; 215 | esac 216 | Show 0 "Your hardware architecture is : $UNAME_M" 217 | CASA_PACKAGES=( 218 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-Gateway/releases/download/v0.4.0/linux-${TARGET_ARCH}-casaos-gateway-v0.4.0.tar.gz" 219 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-MessageBus/releases/download/v0.4.0/linux-${TARGET_ARCH}-casaos-message-bus-v0.4.0.tar.gz" 220 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-UserService/releases/download/v0.4.0/linux-${TARGET_ARCH}-casaos-user-service-v0.4.0.tar.gz" 221 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-LocalStorage/releases/download/v0.4.0/linux-${TARGET_ARCH}-casaos-local-storage-v0.4.0.tar.gz" 222 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-AppManagement/releases/download/v0.4.0/linux-${TARGET_ARCH}-casaos-app-management-v0.4.0.tar.gz" 223 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS/releases/download/v0.4.0/linux-${TARGET_ARCH}-casaos-v0.4.0.tar.gz" 224 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-CLI/releases/download/v0.4.0/linux-${TARGET_ARCH}-casaos-cli-v0.4.0.tar.gz" 225 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-UI/releases/download/v0.4.0/linux-all-casaos-v0.4.0.tar.gz" 226 | ) 227 | } 228 | 229 | # PACKAGE LIST OF CASAOS (make sure the services are in the right order) 230 | CASA_SERVICES=( 231 | "casaos-gateway.service" 232 | "casaos-message-bus.service" 233 | "casaos-user-service.service" 234 | "casaos-local-storage.service" 235 | "casaos-app-management.service" 236 | "casaos.service" # must be the last one so update from UI can work 237 | ) 238 | 239 | # 2 Check Distribution 240 | Check_Distribution() { 241 | sType=0 242 | notice="" 243 | case $LSB_DIST in 244 | *debian*) ;; 245 | 246 | *ubuntu*) ;; 247 | 248 | *raspbian*) ;; 249 | 250 | *openwrt*) 251 | Show 1 "Aborted, OpenWrt cannot be installed using this script." 252 | exit 1 253 | ;; 254 | *alpine*) 255 | Show 1 "Aborted, Alpine installation is not yet supported." 256 | exit 1 257 | ;; 258 | *trisquel*) ;; 259 | 260 | *) 261 | sType=1 262 | notice="We have not tested it on this system and it may fail to install." 263 | ;; 264 | esac 265 | Show ${sType} "Your Linux Distribution is : ${LSB_DIST} ${notice}" 266 | 267 | if [[ ${sType} == 1 ]]; then 268 | select yn in "Yes" "No"; do 269 | case $yn in 270 | [yY][eE][sS] | [yY]) 271 | Show 0 "Distribution check has been ignored." 272 | break 273 | ;; 274 | [nN][oO] | [nN]) 275 | Show 1 "Already exited the installation." 276 | exit 1 277 | ;; 278 | esac 279 | done < /dev/tty # < /dev/tty is used to read the input from the terminal 280 | fi 281 | } 282 | 283 | # 3 Check OS 284 | Check_OS() { 285 | if [[ $UNAME_U == *Linux* ]]; then 286 | Show 0 "Your System is : $UNAME_U" 287 | else 288 | Show 1 "This script is only for Linux." 289 | exit 1 290 | fi 291 | } 292 | 293 | # 4 Check Memory 294 | Check_Memory() { 295 | if [[ "${PHYSICAL_MEMORY}" -lt "${MINIMUM_MEMORY}" ]]; then 296 | Show 1 "requires atleast 1GB physical memory." 297 | exit 1 298 | fi 299 | Show 0 "Memory capacity check passed." 300 | } 301 | 302 | # 5 Check Disk 303 | Check_Disk() { 304 | if [[ "${FREE_DISK_GB}" -lt "${MINIMUM_DISK_SIZE_GB}" ]]; then 305 | echo -e "${aCOLOUR[4]}Recommended free disk space is greater than ${MINIMUM_DISK_SIZE_GB}GB, Current free disk space is ${aCOLOUR[3]}${FREE_DISK_GB}GB${COLOUR_RESET}${aCOLOUR[4]}.\nContinue installation?${COLOUR_RESET}" 306 | select yn in "Yes" "No"; do 307 | case $yn in 308 | [yY][eE][sS] | [yY]) 309 | Show 0 "Disk capacity check has been ignored." 310 | break 311 | ;; 312 | [nN][oO] | [nN]) 313 | Show 1 "Already exited the installation." 314 | exit 1 315 | ;; 316 | esac 317 | done < /dev/tty # < /dev/tty is used to read the input from the terminal 318 | else 319 | Show 0 "Disk capacity check passed." 320 | fi 321 | } 322 | 323 | # Check Port Use 324 | Check_Port() { 325 | TCPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l) 326 | UDPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "udp" && $NF == "0.0.0.0:*" {print $0}' | wc -l) 327 | ((Listeningnum = TCPListeningnum + UDPListeningnum)) 328 | if [[ $Listeningnum == 0 ]]; then 329 | echo "0" 330 | else 331 | echo "1" 332 | fi 333 | } 334 | 335 | # Get an available port 336 | Get_Port() { 337 | CurrentPort=$(${sudo_cmd} cat ${CASA_CONF_PATH} | grep HttpPort | awk '{print $3}') 338 | if [[ $CurrentPort == "$Port" ]]; then 339 | for PORT in {80..65536}; do 340 | if [[ $(Check_Port "$PORT") == 0 ]]; then 341 | Port=$PORT 342 | break 343 | fi 344 | done 345 | else 346 | Port=$CurrentPort 347 | fi 348 | } 349 | 350 | # Update package 351 | 352 | Update_Package_Resource() { 353 | GreyStart 354 | if [ -x "$(command -v apk)" ]; then 355 | ${sudo_cmd} apk update 356 | elif [ -x "$(command -v apt-get)" ]; then 357 | ${sudo_cmd} apt-get update 358 | elif [ -x "$(command -v dnf)" ]; then 359 | ${sudo_cmd} dnf check-update 360 | elif [ -x "$(command -v zypper)" ]; then 361 | ${sudo_cmd} zypper update 362 | elif [ -x "$(command -v yum)" ]; then 363 | ${sudo_cmd} yum update 364 | fi 365 | ColorReset 366 | } 367 | 368 | # Install depends package 369 | Install_Depends() { 370 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 371 | cmd=${CASA_DEPANDS_COMMAND[i]} 372 | if [[ ! -x $(${sudo_cmd} which "$cmd") ]]; then 373 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 374 | Show 2 "Install the necessary dependencies: \e[33m$packagesNeeded \e[0m" 375 | GreyStart 376 | if [ -x "$(command -v apk)" ]; then 377 | ${sudo_cmd} apk add --no-cache "$packagesNeeded" 378 | elif [ -x "$(command -v apt-get)" ]; then 379 | ${sudo_cmd} apt-get -y -q install "$packagesNeeded" --no-upgrade 380 | elif [ -x "$(command -v dnf)" ]; then 381 | ${sudo_cmd} dnf install "$packagesNeeded" 382 | elif [ -x "$(command -v zypper)" ]; then 383 | ${sudo_cmd} zypper install "$packagesNeeded" 384 | elif [ -x "$(command -v yum)" ]; then 385 | ${sudo_cmd} yum install "$packagesNeeded" 386 | elif [ -x "$(command -v pacman)" ]; then 387 | ${sudo_cmd} pacman -S "$packagesNeeded" 388 | elif [ -x "$(command -v paru)" ]; then 389 | ${sudo_cmd} paru -S "$packagesNeeded" 390 | else 391 | Show 1 "Package manager not found. You must manually install: \e[33m$packagesNeeded \e[0m" 392 | fi 393 | ColorReset 394 | fi 395 | done 396 | } 397 | 398 | Check_Dependency_Installation() { 399 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 400 | cmd=${CASA_DEPANDS_COMMAND[i]} 401 | if [[ ! -x $(${sudo_cmd} which "$cmd") ]]; then 402 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 403 | Show 1 "Dependency \e[33m$packagesNeeded \e[0m installation failed, please try again manually!" 404 | exit 1 405 | fi 406 | done 407 | } 408 | 409 | # Check Docker running 410 | Check_Docker_Running() { 411 | for ((i = 1; i <= 3; i++)); do 412 | sleep 3 413 | if [[ ! $(${sudo_cmd} systemctl is-active docker) == "active" ]]; then 414 | Show 1 "Docker is not running, try to start" 415 | ${sudo_cmd} systemctl start docker 416 | else 417 | break 418 | fi 419 | done 420 | } 421 | 422 | #Check Docker Installed and version 423 | Check_Docker_Install() { 424 | if [[ -x "$(command -v docker)" ]]; then 425 | Docker_Version=$(${sudo_cmd} docker version --format '{{.Server.Version}}') 426 | if [[ $? -ne 0 ]]; then 427 | Install_Docker 428 | elif [[ ${Docker_Version:0:2} -lt "${MINIMUM_DOCER_VERSION}" ]]; then 429 | Show 1 "Recommended minimum Docker version is \e[33m${MINIMUM_DOCER_VERSION}.xx.xx\e[0m,\Current Docker verison is \e[33m${Docker_Version}\e[0m,\nPlease uninstall current Docker and rerun the CasaOS installation script." 430 | exit 1 431 | else 432 | Show 0 "Current Docker verison is ${Docker_Version}." 433 | fi 434 | else 435 | Install_Docker 436 | fi 437 | } 438 | 439 | # Check Docker installed 440 | Check_Docker_Install_Final() { 441 | if [[ -x "$(command -v docker)" ]]; then 442 | Docker_Version=$(${sudo_cmd} docker version --format '{{.Server.Version}}') 443 | if [[ $? -ne 0 ]]; then 444 | Install_Docker 445 | elif [[ ${Docker_Version:0:2} -lt "${MINIMUM_DOCER_VERSION}" ]]; then 446 | Show 1 "Recommended minimum Docker version is \e[33m${MINIMUM_DOCER_VERSION}.xx.xx\e[0m,\Current Docker verison is \e[33m${Docker_Version}\e[0m,\nPlease uninstall current Docker and rerun the CasaOS installation script." 447 | exit 1 448 | else 449 | Show 0 "Current Docker verison is ${Docker_Version}." 450 | Check_Docker_Running 451 | fi 452 | else 453 | Show 1 "Installation failed, please run 'curl -fsSL https://get.docker.com | bash' and rerun the CasaOS installation script." 454 | exit 1 455 | fi 456 | } 457 | 458 | #Install Docker 459 | Install_Docker() { 460 | Show 2 "Install the necessary dependencies: \e[33mDocker \e[0m" 461 | GreyStart 462 | if [[ "${REGION}" = "CN" ]]; then 463 | ${sudo_cmd} curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun 464 | else 465 | ${sudo_cmd} curl -fsSL https://get.docker.com | bash 466 | fi 467 | ColorReset 468 | if [[ $? -ne 0 ]]; then 469 | Show 1 "Installation failed, please try again." 470 | exit 1 471 | else 472 | Check_Docker_Install_Final 473 | fi 474 | } 475 | 476 | #Configuration Addons 477 | Configuration_Addons() { 478 | Show 2 "Configuration CasaOS Addons" 479 | #Remove old udev rules 480 | if [[ -f "${PREFIX}/etc/udev/rules.d/11-usb-mount.rules" ]]; then 481 | ${sudo_cmd} rm -rf "${PREFIX}/etc/udev/rules.d/11-usb-mount.rules" 482 | fi 483 | 484 | if [[ -f "${PREFIX}/etc/systemd/system/usb-mount@.service" ]]; then 485 | ${sudo_cmd} rm -rf "${PREFIX}/etc/systemd/system/usb-mount@.service" 486 | fi 487 | 488 | #Udevil 489 | if [[ -f $PREFIX${UDEVIL_CONF_PATH} ]]; then 490 | 491 | # GreyStart 492 | # Add a devmon user 493 | USERNAME=devmon 494 | id ${USERNAME} &>/dev/null || { 495 | ${sudo_cmd} useradd -M -u 300 ${USERNAME} 496 | ${sudo_cmd} usermod -L ${USERNAME} 497 | } 498 | 499 | # Add and start Devmon service 500 | GreyStart 501 | ${sudo_cmd} systemctl enable devmon@devmon 502 | ${sudo_cmd} systemctl start devmon@devmon 503 | ColorReset 504 | # ColorReset 505 | fi 506 | } 507 | 508 | # Download And Install CasaOS 509 | DownloadAndInstallCasaOS() { 510 | if [ -z "${BUILD_DIR}" ]; then 511 | ${sudo_cmd} rm -rf ${TMP_ROOT} 512 | mkdir -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory" 513 | TMP_DIR=$(${sudo_cmd} mktemp -d -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory") 514 | 515 | pushd "${TMP_DIR}" 516 | 517 | for PACKAGE in "${CASA_PACKAGES[@]}"; do 518 | Show 2 "Downloading ${PACKAGE}..." 519 | GreyStart 520 | ${sudo_cmd} curl -sLO "${PACKAGE}" || Show 1 "Failed to download package" 521 | ColorReset 522 | done 523 | 524 | for PACKAGE_FILE in linux-*-casaos-*.tar.gz; do 525 | Show 2 "Extracting ${PACKAGE_FILE}..." 526 | GreyStart 527 | ${sudo_cmd} tar zxf "${PACKAGE_FILE}" || Show 1 "Failed to extract package" 528 | ColorReset 529 | done 530 | 531 | BUILD_DIR=$(${sudo_cmd} realpath -e "${TMP_DIR}"/build || Show 1 "Failed to find build directory") 532 | 533 | popd 534 | fi 535 | 536 | for SERVICE in "${CASA_SERVICES[@]}"; do 537 | Show 2 "Stopping ${SERVICE}..." 538 | GreyStart 539 | ${sudo_cmd} systemctl stop "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 540 | ColorReset 541 | done 542 | 543 | MIGRATION_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/migration/script.d || Show 1 "Failed to find migration script directory") 544 | 545 | for MIGRATION_SCRIPT in "${MIGRATION_SCRIPT_DIR}"/*.sh; do 546 | Show 2 "Running ${MIGRATION_SCRIPT}..." 547 | GreyStart 548 | ${sudo_cmd} bash "${MIGRATION_SCRIPT}" || Show 1 "Failed to run migration script" 549 | ColorReset 550 | done 551 | 552 | Show 2 "Installing CasaOS..." 553 | SYSROOT_DIR=$(realpath -e "${BUILD_DIR}"/sysroot || Show 1 "Failed to find sysroot directory") 554 | 555 | # Generate manifest for uninstallation 556 | MANIFEST_FILE=${BUILD_DIR}/sysroot/var/lib/casaos/manifest 557 | ${sudo_cmd} touch "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 558 | 559 | GreyStart 560 | find "${SYSROOT_DIR}" -type f | ${sudo_cmd} cut -c ${#SYSROOT_DIR}- | ${sudo_cmd} cut -c 2- | ${sudo_cmd} tee "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 561 | 562 | ${sudo_cmd} cp -rf "${SYSROOT_DIR}"/* / || Show 1 "Failed to install CasaOS" 563 | ColorReset 564 | 565 | SETUP_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/setup/script.d || Show 1 "Failed to find setup script directory") 566 | 567 | for SETUP_SCRIPT in "${SETUP_SCRIPT_DIR}"/*.sh; do 568 | Show 2 "Running ${SETUP_SCRIPT}..." 569 | GreyStart 570 | ${sudo_cmd} bash "${SETUP_SCRIPT}" || Show 1 "Failed to run setup script" 571 | ColorReset 572 | done 573 | 574 | #Download Uninstall Script 575 | if [[ -f $PREFIX/tmp/casaos-uninstall ]]; then 576 | ${sudo_cmd} rm -rf "$PREFIX/tmp/casaos-uninstall" 577 | fi 578 | ${sudo_cmd} curl -fsSLk "$CASA_UNINSTALL_URL" >"$PREFIX/tmp/casaos-uninstall" 579 | ${sudo_cmd} cp -rf "$PREFIX/tmp/casaos-uninstall" $CASA_UNINSTALL_PATH || { 580 | Show 1 "Download uninstall script failed, Please check if your internet connection is working and retry." 581 | exit 1 582 | } 583 | 584 | ${sudo_cmd} chmod +x $CASA_UNINSTALL_PATH 585 | 586 | for SERVICE in "${CASA_SERVICES[@]}"; do 587 | Show 2 "Starting ${SERVICE}..." 588 | GreyStart 589 | ${sudo_cmd} systemctl start "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 590 | ColorReset 591 | done 592 | } 593 | 594 | Clean_Temp_Files() { 595 | Show 2 "Clean temporary files..." 596 | ${sudo_cmd} rm -rf "${TMP_DIR}" || Show 1 "Failed to clean temporary files" 597 | } 598 | 599 | Check_Service_status() { 600 | for SERVICE in "${CASA_SERVICES[@]}"; do 601 | Show 2 "Checking ${SERVICE}..." 602 | if [[ $(${sudo_cmd} systemctl is-active "${SERVICE}") == "active" ]]; then 603 | Show 0 "${SERVICE} is running." 604 | else 605 | Show 1 "${SERVICE} is not running, Please reinstall." 606 | exit 1 607 | fi 608 | done 609 | } 610 | 611 | # Get the physical NIC IP 612 | Get_IPs() { 613 | PORT=$(${sudo_cmd} cat ${CASA_CONF_PATH} | grep port | sed 's/port=//') 614 | ALL_NIC=$($sudo_cmd ls /sys/class/net/ | grep -v "$(ls /sys/devices/virtual/net/)") 615 | for NIC in ${ALL_NIC}; do 616 | IP=$($sudo_cmd ifconfig "${NIC}" | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | sed -e 's/addr://g') 617 | if [[ -n $IP ]]; then 618 | if [[ "$PORT" -eq "80" ]]; then 619 | echo -e "${GREEN_BULLET} http://$IP (${NIC})" 620 | else 621 | echo -e "${GREEN_BULLET} http://$IP:$PORT (${NIC})" 622 | fi 623 | fi 624 | done 625 | } 626 | 627 | # Show Welcome Banner 628 | Welcome_Banner() { 629 | CASA_TAG=$(casaos -v) 630 | 631 | echo -e "${GREEN_LINE}${aCOLOUR[1]}" 632 | echo -e " CasaOS ${CASA_TAG}${COLOUR_RESET} is running at${COLOUR_RESET}${GREEN_SEPARATOR}" 633 | echo -e "${GREEN_LINE}" 634 | Get_IPs 635 | echo -e " Open your browser and visit the above address." 636 | echo -e "${GREEN_LINE}" 637 | echo -e "" 638 | echo -e " ${aCOLOUR[2]}CasaOS Project : https://github.com/IceWhaleTech/CasaOS" 639 | echo -e " ${aCOLOUR[2]}CasaOS Team : https://github.com/IceWhaleTech/CasaOS#maintainers" 640 | echo -e " ${aCOLOUR[2]}CasaOS Discord : https://discord.gg/knqAbbBbeX" 641 | echo -e " ${aCOLOUR[2]}Website : https://www.casaos.io" 642 | echo -e " ${aCOLOUR[2]}Online Demo : http://demo.casaos.io" 643 | echo -e "" 644 | echo -e " ${COLOUR_RESET}${aCOLOUR[1]}Uninstall ${COLOUR_RESET}: casaos-uninstall" 645 | echo -e "${COLOUR_RESET}" 646 | } 647 | 648 | ############################################################################### 649 | # Main # 650 | ############################################################################### 651 | 652 | #Usage 653 | usage() { 654 | cat <<-EOF 655 | Usage: install.sh [options] 656 | Valid options are: 657 | -p Specify build directory (Local install) 658 | -h Show this help message and exit 659 | EOF 660 | exit "$1" 661 | } 662 | 663 | while getopts ":p:h" arg; do 664 | case "$arg" in 665 | p) 666 | BUILD_DIR=$OPTARG 667 | ;; 668 | h) 669 | usage 0 670 | ;; 671 | *) 672 | usage 1 673 | ;; 674 | esac 675 | done 676 | 677 | # Step 0 : Get Download Url Domain 678 | Get_Download_Url_Domain 679 | # Step 1: Check ARCH 680 | Check_Arch 681 | 682 | # Step 2: Check OS 683 | Check_OS 684 | 685 | # Step 3: Check Distribution 686 | Check_Distribution 687 | 688 | # Step 4: Check System Required 689 | Check_Memory 690 | Check_Disk 691 | 692 | # Step 5: Install Depends 693 | Update_Package_Resource 694 | Install_Depends 695 | Check_Dependency_Installation 696 | 697 | # Step 6: Check And Install Docker 698 | Check_Docker_Install 699 | 700 | # Step 7: Configuration Addon 701 | Configuration_Addons 702 | 703 | # Step 8: Download And Install CasaOS 704 | DownloadAndInstallCasaOS 705 | 706 | # Step 9: Check Service Status 707 | Check_Service_status 708 | 709 | # Step 10: Clear Term and Show Welcome Banner 710 | Welcome_Banner 711 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # CasaOS Uninstaller Script 4 | # 5 | # GitHub: https://github.com/IceWhaleTech/CasaOS 6 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 7 | # Requires: bash, mv, rm, tr, grep, sed 8 | # 9 | # This script installs CasaOS to your system. 10 | 11 | # In automated environments, you may want to run as root. 12 | # If using curl, we recommend using the -fsSL flags. 13 | # 14 | # This only work on Linux systems. Please 15 | # open an issue if you notice any bugs. 16 | # 17 | set -e 18 | clear 19 | 20 | # shellcheck disable=SC2016 21 | echo ' 22 | _____ ____ _____ 23 | / ____| / __ \ / ____| 24 | | | __ _ ___ __ _| | | | (___ 25 | | | / _` / __|/ _` | | | |\___ \ 26 | | |___| (_| \__ \ (_| | |__| |____) | 27 | \_____\__,_|___/\__,_|\____/|_____/ 28 | 29 | --- Made by IceWhale with YOU --- 30 | ' 31 | 32 | ############################################################################### 33 | # Golbals # 34 | ############################################################################### 35 | 36 | # Not every platform has or needs sudo (https://termux.com/linux.html) 37 | ((EUID)) && sudo_cmd="sudo" 38 | 39 | readonly CASA_SERVICES=( 40 | "casaos-gateway.service" 41 | "casaos-user-service.service" 42 | "casaos.service" 43 | "casaos-local-storage.service" 44 | "devmon@devmon.service" 45 | ) 46 | 47 | readonly CASA_PATH=/casaOS 48 | readonly CASA_EXEC=casaos 49 | readonly CASA_BIN=/usr/local/bin/casaos 50 | readonly CASA_SERVICE_USR=/usr/lib/systemd/system/casaos.service 51 | readonly CASA_SERVICE_LIB=/lib/systemd/system/casaos.service 52 | readonly CASA_SERVICE_ETC=/etc/systemd/system/casaos.service 53 | readonly CASA_ADDON1=/etc/udev/rules.d/11-usb-mount.rules 54 | readonly CASA_ADDON2=/etc/systemd/system/usb-mount@.service 55 | readonly CASA_UNINSTALL_PATH=/usr/bin/casaos-uninstall 56 | 57 | # New Casa Files 58 | readonly MANIFEST=/var/lib/casaos/manifest 59 | readonly CASA_CONF_PATH_OLD=/etc/casaos.conf 60 | readonly CASA_CONF_PATH=/etc/casaos 61 | readonly CASA_RUN_PATH=/var/run/casaos 62 | readonly CASA_USER_FILES=/var/lib/casaos 63 | readonly CASA_LOGS_PATH=/var/log/casaos 64 | readonly CASA_HELPER_PATH=/usr/share/casaos 65 | 66 | readonly COLOUR_RESET='\e[0m' 67 | readonly aCOLOUR=( 68 | '\e[38;5;154m' # green | Lines, bullets and separators 69 | '\e[1m' # Bold white | Main descriptions 70 | '\e[90m' # Grey | Credits 71 | '\e[91m' # Red | Update notifications Alert 72 | '\e[33m' # Yellow | Emphasis 73 | ) 74 | 75 | UNINSTALL_ALL_CONTAINER=false 76 | REMOVE_IMAGES="none" 77 | REMOVE_APP_DATA=false 78 | 79 | ############################################################################### 80 | # Helpers # 81 | ############################################################################### 82 | 83 | ####################################### 84 | # Custom printing function 85 | # Globals: 86 | # None 87 | # Arguments: 88 | # $1 0:OK 1:FAILED 2:INFO 3:NOTICE 89 | # message 90 | # Returns: 91 | # None 92 | ####################################### 93 | 94 | Show() { 95 | # OK 96 | if (($1 == 0)); then 97 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} OK $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 98 | # FAILED 99 | elif (($1 == 1)); then 100 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[3]}FAILED$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 101 | # INFO 102 | elif (($1 == 2)); then 103 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[0]} INFO $COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 104 | # NOTICE 105 | elif (($1 == 3)); then 106 | echo -e "${aCOLOUR[2]}[$COLOUR_RESET${aCOLOUR[4]}NOTICE$COLOUR_RESET${aCOLOUR[2]}]$COLOUR_RESET $2" 107 | fi 108 | } 109 | 110 | Warn() { 111 | echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" 112 | } 113 | 114 | trap 'onCtrlC' INT 115 | onCtrlC() { 116 | echo -e "${COLOUR_RESET}" 117 | exit 1 118 | } 119 | 120 | Detecting_CasaOS() { 121 | if [[ ! -x "$(command -v ${CASA_EXEC})" ]]; then 122 | Show 2 "CasaOS is not detected, exit the script." 123 | exit 1 124 | else 125 | Show 0 "This script will delete the containers you no longer use, and the CasaOS configuration files." 126 | fi 127 | } 128 | 129 | Unistall_Container() { 130 | if [[ ${UNINSTALL_ALL_CONTAINER} == true && "$(${sudo_cmd} docker ps -aq)" != "" ]]; then 131 | Show 2 "Start deleting containers." 132 | ${sudo_cmd} docker stop "$(${sudo_cmd} docker ps -aq)" || Show 1 "Failed to stop containers." 133 | ${sudo_cmd} docker rm "$(${sudo_cmd} docker ps -aq)" || Show 1 "Failed to delete all containers." 134 | fi 135 | } 136 | 137 | Remove_Images() { 138 | if [[ ${REMOVE_IMAGES} == "all" && "$(${sudo_cmd} docker images -q)" != "" ]]; then 139 | Show 2 "Start deleting all images." 140 | ${sudo_cmd} docker rmi "$(${sudo_cmd} docker images -q)" || Show 1 "Failed to delete all images." 141 | elif [[ ${REMOVE_IMAGES} == "unuse" && "$(${sudo_cmd} docker images -q)" != "" ]]; then 142 | Show 2 "Start deleting unuse images." 143 | ${sudo_cmd} docker image prune -af || Show 1 "Failed to delete unuse images." 144 | fi 145 | } 146 | 147 | Uninstall_Casaos() { 148 | 149 | for SERVICE in "${CASA_SERVICES[@]}"; do 150 | Show 2 "Stopping ${SERVICE}..." 151 | systemctl stop "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 152 | systemctl disable "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 153 | done 154 | 155 | # Remove Service file 156 | if [[ -f ${CASA_SERVICE_USR} ]]; then 157 | ${sudo_cmd} rm -rf ${CASA_SERVICE_USR} 158 | fi 159 | 160 | if [[ -f ${CASA_SERVICE_LIB} ]]; then 161 | ${sudo_cmd} rm -rf ${CASA_SERVICE_LIB} 162 | fi 163 | 164 | if [[ -f ${CASA_SERVICE_ETC} ]]; then 165 | ${sudo_cmd} rm -rf ${CASA_SERVICE_ETC} 166 | fi 167 | 168 | # Old Casa Files 169 | if [[ -d ${CASA_PATH} ]]; then 170 | ${sudo_cmd} rm -rf ${CASA_PATH} || Show 1 "Failed to delete CasaOS files." 171 | fi 172 | 173 | if [[ -f ${CASA_ADDON1} ]]; then 174 | ${sudo_cmd} rm -rf ${CASA_ADDON1} 175 | fi 176 | 177 | if [[ -f ${CASA_ADDON2} ]]; then 178 | ${sudo_cmd} rm -rf ${CASA_ADDON2} 179 | fi 180 | 181 | if [[ -f ${CASA_BIN} ]]; then 182 | ${sudo_cmd} rm -rf ${CASA_BIN} || Show 1 "Failed to delete CasaOS exec file." 183 | fi 184 | 185 | # New Casa Files 186 | 187 | if [[ -f ${CASA_CONF_PATH_OLD} ]]; then 188 | ${sudo_cmd} rm -rf ${CASA_CONF_PATH_OLD} 189 | fi 190 | 191 | if [[ -f ${MANIFEST} ]]; then 192 | ${sudo_cmd} cat ${MANIFEST} | while read -r line; do 193 | if [[ -f ${line} ]]; then 194 | ${sudo_cmd} rm -rf "${line}" 195 | fi 196 | done 197 | fi 198 | 199 | if [[ -d ${CASA_USER_FILES} ]]; then 200 | ${sudo_cmd} rm -rf ${CASA_USER_FILES}/[0-9]* 201 | ${sudo_cmd} rm -rf ${CASA_USER_FILES}/db 202 | ${sudo_cmd} rm -rf ${CASA_USER_FILES}/*.db 203 | fi 204 | 205 | ${sudo_cmd} rm -rf ${CASA_USER_FILES}/www 206 | ${sudo_cmd} rm -rf ${CASA_USER_FILES}/migration 207 | 208 | if [[ -d ${CASA_HELPER_PATH} ]]; then 209 | ${sudo_cmd} rm -rf ${CASA_HELPER_PATH} 210 | fi 211 | 212 | if [[ -d ${CASA_LOGS_PATH} ]]; then 213 | ${sudo_cmd} rm -rf ${CASA_LOGS_PATH} 214 | fi 215 | 216 | if [[ ${REMOVE_APP_DATA} = true ]]; then 217 | $sudo_cmd rm -fr /DATA/AppData || Show 1 "Failed to delete AppData." 218 | fi 219 | 220 | if [[ -d ${CASA_CONF_PATH} ]]; then 221 | ${sudo_cmd} rm -rf ${CASA_CONF_PATH} 222 | fi 223 | 224 | if [[ -d ${CASA_RUN_PATH} ]]; then 225 | ${sudo_cmd} rm -rf ${CASA_RUN_PATH} 226 | fi 227 | 228 | if [[ -f ${CASA_UNINSTALL_PATH} ]]; then 229 | ${sudo_cmd} rm -rf ${CASA_UNINSTALL_PATH} 230 | fi 231 | 232 | } 233 | 234 | # Check user 235 | if [ "$(id -u)" -ne 0 ];then 236 | Show 1 "Please execute with a root user, or use ${aCOLOUR[4]}sudo casaos-uninstall${COLOUR_RESET}." 237 | exit 1 238 | fi 239 | 240 | 241 | #Inputs 242 | 243 | Detecting_CasaOS 244 | 245 | while true; do 246 | echo -n -e " ${aCOLOUR[4]}Do you want delete all containers? Y/n :${COLOUR_RESET}" 247 | read -r input 248 | case $input in 249 | [yY][eE][sS] | [yY]) 250 | UNINSTALL_ALL_CONTAINER=true 251 | break 252 | ;; 253 | [nN][oO] | [nN]) 254 | UNINSTALL_ALL_CONTAINER=false 255 | break 256 | ;; 257 | *) 258 | Warn " Invalid input..." 259 | ;; 260 | esac 261 | done 262 | 263 | if [[ ${UNINSTALL_ALL_CONTAINER} == true ]]; then 264 | while true; do 265 | echo -n -e " ${aCOLOUR[4]}Do you want delete all images? Y/n :${COLOUR_RESET}" 266 | read -r input 267 | case $input in 268 | [yY][eE][sS] | [yY]) 269 | REMOVE_IMAGES="all" 270 | break 271 | ;; 272 | [nN][oO] | [nN]) 273 | REMOVE_IMAGES="none" 274 | break 275 | ;; 276 | *) 277 | Warn " Invalid input..." 278 | ;; 279 | esac 280 | done 281 | 282 | while true; do 283 | echo -n -e " ${aCOLOUR[4]}Do you want delete all AppData of CasaOS? Y/n :${COLOUR_RESET}" 284 | read -r input 285 | case $input in 286 | [yY][eE][sS] | [yY]) 287 | REMOVE_APP_DATA=true 288 | break 289 | ;; 290 | [nN][oO] | [nN]) 291 | REMOVE_APP_DATA=false 292 | break 293 | ;; 294 | *) 295 | Warn " Invalid input..." 296 | ;; 297 | esac 298 | done 299 | else 300 | while true; do 301 | echo -n -e " ${aCOLOUR[4]}Do you want to delete all images that are not used by the container? Y/n :${COLOUR_RESET}" 302 | read -r input 303 | case $input in 304 | [yY][eE][sS] | [yY]) 305 | REMOVE_IMAGES="unuse" 306 | break 307 | ;; 308 | [nN][oO] | [nN]) 309 | REMOVE_IMAGES="none" 310 | break 311 | ;; 312 | *) 313 | Warn " Invalid input..." 314 | ;; 315 | esac 316 | done 317 | fi 318 | 319 | 320 | Unistall_Container 321 | Remove_Images 322 | Uninstall_Casaos 323 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # 3 | # CasaOS Update Script v0.4.4-1# 4 | # GitHub: https://github.com/IceWhaleTech/CasaOS 5 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 6 | # Requires: bash, mv, rm, tr, grep, sed, curl/wget, tar, smartmontools, parted, ntfs-3g, net-tools 7 | # 8 | # This script update your CasaOS. 9 | # Usage: 10 | # 11 | # $ wget -qO- https://get.casaos.io/update | bash 12 | # or 13 | # $ curl -fsSL https://get.casaos.io/update | bash 14 | # 15 | # In automated environments, you may want to run as root. 16 | # If using curl, we recommend using the -fsSL flags. 17 | # 18 | # This only work on Linux systems. Please 19 | # open an issue if you notice any bugs. 20 | # 21 | 22 | 23 | # shellcheck disable=SC2016 24 | echo ' 25 | _____ ____ _____ 26 | / ____| / __ \ / ____| 27 | | | __ _ ___ __ _| | | | (___ 28 | | | / _` / __|/ _` | | | |\___ \ 29 | | |___| (_| \__ \ (_| | |__| |____) | 30 | \_____\__,_|___/\__,_|\____/|_____/ 31 | 32 | --- Made by IceWhale with YOU --- 33 | ' 34 | export PATH=/usr/sbin:$PATH 35 | set -e 36 | 37 | ############################################################################### 38 | # GOLBALS # 39 | ############################################################################### 40 | 41 | ((EUID)) && sudo_cmd="sudo" 42 | 43 | # shellcheck source=/dev/null 44 | source /etc/os-release 45 | 46 | # SYSTEM REQUIREMENTS 47 | readonly CASA_DEPANDS_PACKAGE=('wget' 'curl' 'smartmontools' 'parted' 'ntfs-3g' 'net-tools' 'udevil' 'samba' 'cifs-utils' 'mergerfs' 'unzip' 'apparmor') 48 | readonly CASA_DEPANDS_COMMAND=('wget' 'curl' 'smartctl' 'parted' 'ntfs-3g' 'netstat' 'udevil' 'samba' 'mount.cifs' 'mount.mergerfs' 'unzip' 'apparmor_status') 49 | 50 | LSB_DIST=$( ( [ -n "${ID_LIKE}" ] && echo "${ID_LIKE}" ) || ( [ -n "${ID}" ] && echo "${ID}" ) ) 51 | readonly LSB_DIST 52 | 53 | UNAME_M="$(uname -m)" 54 | readonly UNAME_M 55 | 56 | 57 | readonly CASA_UNINSTALL_URL="https://get.casaos.io/uninstall/v0.4.4-1" 58 | readonly CASA_UNINSTALL_PATH=/usr/bin/casaos-uninstall 59 | 60 | # REQUIREMENTS CONF PATH 61 | # Udevil 62 | readonly UDEVIL_CONF_PATH=/etc/udevil/udevil.conf 63 | readonly DEVMON_CONF_PATH=/etc/conf.d/devmon 64 | 65 | # COLORS 66 | readonly COLOUR_RESET='\e[0m' 67 | readonly aCOLOUR=( 68 | '\e[38;5;154m' # green | Lines, bullets and separators 69 | '\e[1m' # Bold white | Main descriptions 70 | '\e[90m' # Grey | Credits 71 | '\e[91m' # Red | Update notifications Alert 72 | '\e[33m' # Yellow | Emphasis 73 | ) 74 | 75 | 76 | # CASAOS VARIABLES 77 | TARGET_ARCH="" 78 | TMP_ROOT=/tmp/casaos-installer 79 | CASA_DOWNLOAD_DOMAIN="https://github.com/" 80 | 81 | 82 | # PACKAGE LIST OF CASAOS 83 | CASA_SERVICES=( 84 | "casaos-gateway.service" 85 | "casaos-message-bus.service" 86 | "casaos-user-service.service" 87 | "casaos-local-storage.service" 88 | "casaos-app-management.service" 89 | "rclone.service" 90 | "casaos.service" # must be the last one so update from UI can work 91 | ) 92 | 93 | trap 'onCtrlC' INT 94 | onCtrlC() { 95 | echo -e "${COLOUR_RESET}" 96 | exit 1 97 | } 98 | 99 | 100 | upgradePath="/var/log/casaos" 101 | upgradeFile="/var/log/casaos/upgrade.log" 102 | 103 | if [ -f "$upgradePath" ]; then 104 | ${sudo_cmd} rm "$upgradePath" 105 | fi 106 | 107 | if [ ! -d "$upgradePath" ]; then 108 | ${sudo_cmd} mkdir -p "$upgradePath" 109 | fi 110 | 111 | if [ ! -f "$upgradeFile" ]; then 112 | ${sudo_cmd} touch "$upgradeFile" 113 | fi 114 | 115 | ############################################################################### 116 | # Helpers # 117 | ############################################################################### 118 | 119 | ####################################### 120 | # Custom printing function 121 | # Globals: 122 | # None 123 | # Arguments: 124 | # $1 0:OK 1:FAILED 2:INFO 3:NOTICE 125 | # message 126 | # Returns: 127 | # None 128 | ####################################### 129 | 130 | Show() { 131 | # OK 132 | if (($1 == 0)); then 133 | echo -e "- OK $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 134 | # FAILED 135 | elif (($1 == 1)); then 136 | echo -e "- FAILED $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 137 | exit 1 138 | # INFO 139 | elif (($1 == 2)); then 140 | echo -e "- INFO $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 141 | # NOTICE 142 | elif (($1 == 3)); then 143 | echo -e "- NOTICE $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 144 | fi 145 | } 146 | 147 | Warn() { 148 | echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" 149 | } 150 | 151 | GreyStart() { 152 | echo -e "${aCOLOUR[2]}\c" 153 | } 154 | 155 | ColorReset() { 156 | echo -e "$COLOUR_RESET\c" 157 | } 158 | 159 | # Check file exists 160 | exist_file() { 161 | if [ -e "$1" ]; then 162 | return 1 163 | else 164 | return 2 165 | fi 166 | } 167 | 168 | ############################################################################### 169 | # FUNCTIONS # 170 | ############################################################################### 171 | 172 | # 0 Get download url domain 173 | # To solve the problem that Chinese users cannot access github. 174 | Get_Download_Url_Domain() { 175 | # Use ipconfig.io/country and https://ifconfig.io/country_code to get the country code 176 | REGION=$(${sudo_cmd} curl --connect-timeout 2 -s ipconfig.io/country || echo "") 177 | if [ "${REGION}" = "" ]; then 178 | REGION=$(${sudo_cmd} curl --connect-timeout 2 -s https://ifconfig.io/country_code || echo "") 179 | fi 180 | if [[ "${REGION}" = "China" ]] || [[ "${REGION}" = "CN" ]]; then 181 | CASA_DOWNLOAD_DOMAIN="https://casaos.oss-cn-shanghai.aliyuncs.com/" 182 | fi 183 | } 184 | 185 | # 1 Check Arch 186 | Check_Arch() { 187 | case $UNAME_M in 188 | *aarch64*) 189 | TARGET_ARCH="arm64" 190 | ;; 191 | *riscv64*) 192 | TARGET_ARCH="riscv64" 193 | ;; 194 | *64*) 195 | TARGET_ARCH="amd64" 196 | ;; 197 | *armv7*) 198 | TARGET_ARCH="arm-7" 199 | ;; 200 | *) 201 | Show 1 "Aborted, unsupported or unknown architecture: $UNAME_M" 202 | exit 1 203 | ;; 204 | esac 205 | Show 0 "Your hardware architecture is : $UNAME_M" 206 | CASA_PACKAGES=( 207 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-Gateway/releases/download/v0.4.4-1/linux-${TARGET_ARCH}-casaos-gateway-v0.4.4-1.tar.gz" 208 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-MessageBus/releases/download/v0.4.4/linux-${TARGET_ARCH}-casaos-message-bus-v0.4.4.tar.gz" 209 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-UserService/releases/download/v0.4.4/linux-${TARGET_ARCH}-casaos-user-service-v0.4.4.tar.gz" 210 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-LocalStorage/releases/download/v0.4.4/linux-${TARGET_ARCH}-casaos-local-storage-v0.4.4.tar.gz" 211 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-AppManagement/releases/download/v0.4.4-1/linux-${TARGET_ARCH}-casaos-app-management-v0.4.4-1.tar.gz" 212 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS/releases/download/v0.4.4/linux-${TARGET_ARCH}-casaos-v0.4.4.tar.gz" 213 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-CLI/releases/download/v0.4.4/linux-${TARGET_ARCH}-casaos-cli-v0.4.4.tar.gz" 214 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-UI/releases/download/v0.4.4-1/linux-all-casaos-v0.4.4-1.tar.gz" 215 | "${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS-AppStore/releases/download/v0.4.4/linux-all-appstore-v0.4.4.tar.gz" 216 | ) 217 | } 218 | 219 | # 2 Check Distribution 220 | Check_Distribution() { 221 | sType=0 222 | notice="" 223 | case $LSB_DIST in 224 | *debian*) 225 | ;; 226 | *ubuntu*) 227 | ;; 228 | *raspbian*) 229 | ;; 230 | *openwrt*) 231 | Show 1 "Aborted, OpenWrt cannot be installed using this script, please visit ${CASA_OPENWRT_DOCS}." 232 | exit 1 233 | ;; 234 | *alpine*) 235 | Show 1 "Aborted, Alpine installation is not yet supported." 236 | exit 1 237 | ;; 238 | *trisquel*) 239 | ;; 240 | *) 241 | sType=3 242 | notice="We have not tested it on this system and it may fail to install." 243 | ;; 244 | esac 245 | Show ${sType} "Your Linux Distribution is : ${LSB_DIST} ${notice}" 246 | if [[ ${sType} == 0 ]]; then 247 | select yn in "Yes" "No"; do 248 | case $yn in 249 | [yY][eE][sS] | [yY]) 250 | Show 0 "Distribution check has been ignored." 251 | break 252 | ;; 253 | [nN][oO] | [nN]) 254 | Show 1 "Already exited the installation." 255 | exit 1 256 | ;; 257 | esac 258 | done 259 | fi 260 | } 261 | 262 | # Check Port Use 263 | Check_Port() { 264 | TCPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l) 265 | UDPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "udp" && $NF == "0.0.0.0:*" {print $0}' | wc -l) 266 | ((Listeningnum = TCPListeningnum + UDPListeningnum)) 267 | if [[ $Listeningnum == 0 ]]; then 268 | echo "0" 269 | else 270 | echo "1" 271 | fi 272 | } 273 | 274 | # Update package 275 | 276 | Update_Package_Resource() { 277 | GreyStart 278 | if [ -x "$(command -v apk)" ]; then 279 | ${sudo_cmd} apk update 280 | elif [ -x "$(command -v apt-get)" ]; then 281 | ${sudo_cmd} apt-get update 282 | elif [ -x "$(command -v dnf)" ]; then 283 | ${sudo_cmd} dnf check-update 284 | elif [ -x "$(command -v zypper)" ]; then 285 | ${sudo_cmd} zypper update 286 | elif [ -x "$(command -v yum)" ]; then 287 | ${sudo_cmd} yum update 288 | fi 289 | ColorReset 290 | } 291 | 292 | # Install depends package 293 | Install_Depends() { 294 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 295 | cmd=${CASA_DEPANDS_COMMAND[i]} 296 | if [[ ! -x $(command -v "${cmd}") ]]; then 297 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 298 | Show 2 "Install the necessary dependencies: $packagesNeeded " 299 | GreyStart 300 | if [ -x "$(command -v apk)" ]; then 301 | ${sudo_cmd} apk add --no-cache "$packagesNeeded" 302 | elif [ -x "$(command -v apt-get)" ]; then 303 | ${sudo_cmd} apt-get -y -q install "$packagesNeeded" --no-upgrade 304 | elif [ -x "$(command -v dnf)" ]; then 305 | ${sudo_cmd} dnf install "$packagesNeeded" 306 | elif [ -x "$(command -v zypper)" ]; then 307 | ${sudo_cmd} zypper install "$packagesNeeded" 308 | elif [ -x "$(command -v yum)" ]; then 309 | ${sudo_cmd} yum install "$packagesNeeded" 310 | elif [ -x "$(command -v pacman)" ]; then 311 | ${sudo_cmd} pacman -S "$packagesNeeded" 312 | elif [ -x "$(command -v paru)" ]; then 313 | ${sudo_cmd} paru -S "$packagesNeeded" 314 | else 315 | Show 1 "Package manager not found. You must manually install: $packagesNeeded" 316 | fi 317 | ColorReset 318 | fi 319 | done 320 | } 321 | 322 | Check_Dependency_Installation() { 323 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 324 | cmd=${CASA_DEPANDS_COMMAND[i]} 325 | if [[ ! -x $(command -v "${cmd}") ]]; then 326 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 327 | Show 1 "Dependency \e[33m$packagesNeeded \e[0m installation failed, please try again manually!" 328 | exit 1 329 | fi 330 | done 331 | } 332 | 333 | #Install Rclone 334 | Install_rclone_from_source() { 335 | ${sudo_cmd} wget -qO ./install.sh https://rclone.org/install.sh 336 | if [[ "${REGION}" = "China" ]] || [[ "${REGION}" = "CN" ]]; then 337 | sed -i 's/downloads.rclone.org/casaos.oss-cn-shanghai.aliyuncs.com/g' ./install.sh 338 | else 339 | sed -i 's/downloads.rclone.org/get.casaos.io/g' ./install.sh 340 | fi 341 | ${sudo_cmd} chmod +x ./install.sh 342 | ${sudo_cmd} ./install.sh || { 343 | Show 1 "Installation failed, please try again." 344 | ${sudo_cmd} rm -rf install.sh 345 | exit 1 346 | } 347 | ${sudo_cmd} rm -rf install.sh 348 | Show 0 "Rclone v1.61.1 installed successfully." 349 | } 350 | 351 | Install_Rclone() { 352 | Show 2 "Install the necessary dependencies: Rclone" 353 | if [[ -x "$(command -v rclone)" ]]; then 354 | version=$(rclone --version 2>>errors | head -n 1) 355 | target_version="rclone v1.61.1" 356 | rclone1="${PREFIX}/usr/share/man/man1/rclone.1.gz" 357 | if [ "$version" != "$target_version" ]; then 358 | Show 3 "Will change rclone from $version to $target_version." 359 | rclone_path=$(command -v rclone) 360 | ${sudo_cmd} rm -rf "${rclone_path}" 361 | if [[ -f "$rclone1" ]]; then 362 | ${sudo_cmd} rm -rf "$rclone1" 363 | fi 364 | Install_rclone_from_source 365 | else 366 | Show 2 "Target version already installed." 367 | fi 368 | else 369 | Install_rclone_from_source 370 | fi 371 | ${sudo_cmd} systemctl enable rclone || Show 3 "Service rclone does not exist." 372 | } 373 | 374 | 375 | #Configuration Addons 376 | Configuration_Addons() { 377 | Show 2 "Configuration CasaOS Addons" 378 | #Remove old udev rules 379 | if [[ -f "${PREFIX}/etc/udev/rules.d/11-usb-mount.rules" ]]; then 380 | ${sudo_cmd} rm -rf "${PREFIX}/etc/udev/rules.d/11-usb-mount.rules" 381 | fi 382 | 383 | if [[ -f "${PREFIX}/etc/systemd/system/usb-mount@.service" ]]; then 384 | ${sudo_cmd} rm -rf "${PREFIX}/etc/systemd/system/usb-mount@.service" 385 | fi 386 | 387 | #Udevil 388 | if [[ -f "${PREFIX}${UDEVIL_CONF_PATH}" ]]; then 389 | 390 | # Revert previous CasaOS udevil configuration 391 | #shellcheck disable=SC2016 392 | ${sudo_cmd} sed -i 's/allowed_media_dirs = \/DATA, \/DATA\/$USER/allowed_media_dirs = \/media, \/media\/$USER, \/run\/media\/$USER/g' "${PREFIX}${UDEVIL_CONF_PATH}" 393 | ${sudo_cmd} sed -i '/exfat/s/, nonempty//g' "$PREFIX"${UDEVIL_CONF_PATH} 394 | ${sudo_cmd} sed -i '/default_options/s/, noexec//g' "$PREFIX"${UDEVIL_CONF_PATH} 395 | ${sudo_cmd} sed -i '/^ARGS/cARGS="--mount-options nosuid,nodev,noatime --ignore-label EFI"' "$PREFIX"${DEVMON_CONF_PATH} 396 | 397 | # GreyStart 398 | # Add a devmon user 399 | USERNAME=devmon 400 | id ${USERNAME} &>/dev/null || { 401 | ${sudo_cmd} useradd -M -u 300 ${USERNAME} 402 | ${sudo_cmd} usermod -L ${USERNAME} 403 | } 404 | 405 | # Add and start Devmon service 406 | GreyStart 407 | ${sudo_cmd} systemctl enable devmon@devmon 408 | ${sudo_cmd} systemctl start devmon@devmon 409 | ColorReset 410 | # ColorReset 411 | fi 412 | } 413 | 414 | # Download And Install CasaOS 415 | DownloadAndInstallCasaOS() { 416 | 417 | if [ -z "${BUILD_DIR}" ]; then 418 | 419 | ${sudo_cmd} mkdir -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory" 420 | TMP_DIR=$(${sudo_cmd} mktemp -d -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory") 421 | 422 | pushd "${TMP_DIR}" 423 | 424 | for PACKAGE in "${CASA_PACKAGES[@]}"; do 425 | Show 2 "Downloading ${PACKAGE}..." 426 | 427 | ${sudo_cmd} wget -t 3 -q --show-progress -c "${PACKAGE}" || Show 1 "Failed to download package" 428 | 429 | done 430 | 431 | for PACKAGE_FILE in linux-*.tar.gz; do 432 | Show 2 "Extracting ${PACKAGE_FILE}..." 433 | ${sudo_cmd} tar zxf "${PACKAGE_FILE}" || Show 1 "Failed to extract package" 434 | done 435 | 436 | BUILD_DIR=$(realpath -e "${TMP_DIR}"/build || Show 1 "Failed to find build directory") 437 | 438 | popd 439 | fi 440 | 441 | # for SERVICE in "${CASA_SERVICES[@]}"; do 442 | # Show 2 "Stopping ${SERVICE}..." 443 | 444 | # systemctl stop "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 445 | 446 | # done 447 | 448 | MIGRATION_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/migration/script.d || Show 1 "Failed to find migration script directory") 449 | 450 | for MIGRATION_SCRIPT in "${MIGRATION_SCRIPT_DIR}"/*.sh; do 451 | Show 2 "Running ${MIGRATION_SCRIPT}..." 452 | 453 | ${sudo_cmd} bash "${MIGRATION_SCRIPT}" || Show 1 "Failed to run migration script" 454 | 455 | done 456 | 457 | Show 2 "Installing CasaOS..." 458 | SYSROOT_DIR=$(realpath -e "${BUILD_DIR}"/sysroot || Show 1 "Failed to find sysroot directory") 459 | 460 | # Generate manifest for uninstallation 461 | MANIFEST_FILE=${BUILD_DIR}/sysroot/var/lib/casaos/manifest 462 | ${sudo_cmd} touch "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 463 | 464 | 465 | find "${SYSROOT_DIR}" -type f | ${sudo_cmd} cut -c ${#SYSROOT_DIR}- | ${sudo_cmd} cut -c 2- | ${sudo_cmd} tee "${MANIFEST_FILE}" >/dev/null || Show 1 "Failed to create manifest file" 466 | 467 | ${sudo_cmd} cp -rf "${SYSROOT_DIR}"/* / >> /dev/null || Show 1 "Failed to install CasaOS" 468 | 469 | SETUP_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/setup/script.d || Show 1 "Failed to find setup script directory") 470 | 471 | for SETUP_SCRIPT in "${SETUP_SCRIPT_DIR}"/*.sh; do 472 | Show 2 "Running ${SETUP_SCRIPT}..." 473 | ${sudo_cmd} bash "${SETUP_SCRIPT}" || Show 1 "Failed to run setup script" 474 | done 475 | 476 | # Reset Permissions 477 | UI_EVENTS_REG_SCRIPT=/etc/casaos/start.d/register-ui-events.sh 478 | if [[ -f ${UI_EVENTS_REG_SCRIPT} ]]; then 479 | ${sudo_cmd} chmod +x $UI_EVENTS_REG_SCRIPT 480 | fi 481 | 482 | # Modify app store configuration 483 | sed -i "/ServerAPI/d" "$PREFIX/etc/casaos/app-management.conf" 484 | sed -i "/ServerApi/d" "$PREFIX/etc/casaos/app-management.conf" 485 | sed -i '/appstore/d' "$PREFIX/etc/casaos/app-management.conf" 486 | sed -i "/server/aappstore = ${CASA_DOWNLOAD_DOMAIN}IceWhaleTech/_appstore/archive/refs/heads/main.zip" "$PREFIX/etc/casaos/app-management.conf" 487 | 488 | #Download Uninstall Script 489 | if [[ -f ${PREFIX}/tmp/casaos-uninstall ]]; then 490 | ${sudo_cmd} rm -rf "${PREFIX}/tmp/casaos-uninstall" 491 | fi 492 | ${sudo_cmd} curl -fsSLk "$CASA_UNINSTALL_URL" >"${PREFIX}/tmp/casaos-uninstall" 493 | ${sudo_cmd} cp -rvf "${PREFIX}/tmp/casaos-uninstall" $CASA_UNINSTALL_PATH || { 494 | Show 1 "Download uninstall script failed, Please check if your internet connection is working and retry." 495 | exit 1 496 | } 497 | 498 | ${sudo_cmd} chmod +x $CASA_UNINSTALL_PATH 499 | Install_Rclone 500 | 501 | ## Special markings 502 | 503 | Show 0 "CasaOS upgrade successfully" 504 | for SERVICE in "${CASA_SERVICES[@]}"; do 505 | Show 2 "restart ${SERVICE}..." 506 | 507 | ${sudo_cmd} systemctl restart "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 508 | 509 | done 510 | 511 | 512 | } 513 | 514 | ############################################################################### 515 | # Main # 516 | ############################################################################### 517 | 518 | #Usage 519 | usage() { 520 | cat <<-EOF 521 | Usage: get.sh [options] 522 | Valid options are: 523 | -p Specify build directory 524 | -h Show this help message and exit 525 | EOF 526 | exit "$1" 527 | } 528 | 529 | while getopts ":p:h" arg; do 530 | case "$arg" in 531 | p) 532 | BUILD_DIR=$OPTARG 533 | ;; 534 | h) 535 | usage 0 536 | ;; 537 | *) 538 | usage 1 539 | ;; 540 | esac 541 | done 542 | 543 | # Step 0: Get Download Url Domain 544 | Get_Download_Url_Domain 545 | 546 | # Step 1: Check ARCH 547 | Check_Arch 548 | 549 | # Step 2: Install Depends 550 | Update_Package_Resource 551 | Install_Depends 552 | Check_Dependency_Installation 553 | 554 | 555 | # Step 3: Configuration Addon 556 | Configuration_Addons 557 | 558 | # Step 4: Download And Install CasaOS 559 | DownloadAndInstallCasaOS 560 | -------------------------------------------------------------------------------- /upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # 3 | # CasaOS Installer Script 4 | # 5 | # GitHub: https://github.com/IceWhaleTech/CasaOS 6 | # Issues: https://github.com/IceWhaleTech/CasaOS/issues 7 | # Requires: bash, mv, rm, tr, grep, sed, curl/wget, tar, smartmontools, parted, ntfs-3g, net-tools 8 | # 9 | # This script installs CasaOS to your system. 10 | # Usage: 11 | # 12 | # $ curl -fsSL https://get.casaos.io | bash 13 | # or 14 | # $ wget -qO- https://get.casaos.io | bash 15 | # 16 | # In automated environments, you may want to run as root. 17 | # If using curl, we recommend using the -fsSL flags. 18 | # 19 | # This only work on Linux systems. Please 20 | # open an issue if you notice any bugs. 21 | # 22 | 23 | 24 | 25 | echo ' 26 | _____ ____ _____ 27 | / ____| / __ \ / ____| 28 | | | __ _ ___ __ _| | | | (___ 29 | | | / _` / __|/ _` | | | |\___ \ 30 | | |___| (_| \__ \ (_| | |__| |____) | 31 | \_____\__,_|___/\__,_|\____/|_____/ 32 | 33 | --- Made by IceWhale with YOU --- 34 | ' 35 | 36 | set -e 37 | 38 | ############################################################################### 39 | # GOLBALS # 40 | ############################################################################### 41 | 42 | ((EUID)) && sudo_cmd="sudo" 43 | 44 | readonly TITLE="CasaOS Installer" 45 | 46 | # SYSTEM REQUIREMENTS 47 | readonly MINIMUM_DISK_SIZE_GB="5" 48 | readonly MINIMUM_MEMORY="400" 49 | readonly MINIMUM_DOCER_VERSION="20" 50 | readonly SUPPORTED_DIST=('debian' 'ubuntu' 'raspbian') 51 | readonly CASA_DEPANDS_PACKAGE=('curl' 'smartmontools' 'parted' 'ntfs-3g' 'net-tools' 'whiptail' 'udevil' 'samba' 'cifs-utils') 52 | readonly CASA_DEPANDS_COMMAND=('curl' 'smartctl' 'parted' 'ntfs-3g' 'netstat' 'whiptail' 'udevil' 'samba' 'mount.cifs') 53 | 54 | # SYSTEM INFO 55 | readonly PHYSICAL_MEMORY=$(LC_ALL=C free -m | awk '/Mem:/ { print $2 }') 56 | readonly FREE_DISK_BYTES=$(LC_ALL=C df -P / | tail -n 1 | awk '{print $4}') 57 | readonly FREE_DISK_GB=$((${FREE_DISK_BYTES} / 1024 / 1024)) 58 | readonly LSB_DIST="$(. /etc/os-release && echo "$ID")" 59 | readonly UNAME_M="$(uname -m)" 60 | readonly UNAME_U="$(uname -s)" 61 | readonly NET_GETTER="curl -fsSLk" 62 | 63 | readonly CASA_VERSION_URL="https://api.casaos.io/casaos-api/version" 64 | readonly CASA_UNINSTALL_URL="https://raw.githubusercontent.com/IceWhaleTech/get/main/uninstall.sh" 65 | readonly CASA_UNINSTALL_PATH=/usr/bin/casaos-uninstall 66 | 67 | # REQUIREMENTS CONF PATH 68 | # Udevil 69 | readonly UDEVIL_CONF_PATH=/etc/udevil/udevil.conf 70 | 71 | # COLORS 72 | readonly COLOUR_RESET='\e[0m' 73 | readonly aCOLOUR=( 74 | '\e[38;5;154m' # green | Lines, bullets and separators 75 | '\e[1m' # Bold white | Main descriptions 76 | '\e[90m' # Grey | Credits 77 | '\e[91m' # Red | Update notifications Alert 78 | '\e[33m' # Yellow | Emphasis 79 | ) 80 | 81 | 82 | # CASAOS VARIABLES 83 | TARGET_ARCH="" 84 | TARGET_DISTRO="debian" 85 | TARGET_OS="linux" 86 | CASA_TAG="v0.3.6" 87 | TMP_ROOT=/tmp/casaos-installer 88 | 89 | 90 | # PACKAGE LIST OF CASAOS 91 | 92 | 93 | 94 | CASA_SERVICES=( 95 | "casaos-gateway.service" 96 | "casaos-user-service.service" 97 | "casaos.service" 98 | ) 99 | 100 | trap 'onCtrlC' INT 101 | onCtrlC() { 102 | echo -e "${COLOUR_RESET}" 103 | exit 1 104 | } 105 | 106 | 107 | upgradePath="/var/log/casaos" 108 | upgradeFile="/var/log/casaos/upgrade.log" 109 | 110 | if [ -f "$upgradePath" ]; then 111 | ${sudo_cmd} rm "$upgradePath" 112 | fi 113 | 114 | if [ ! -d "$upgradePath" ]; then 115 | ${sudo_cmd} mkdir -p "$upgradePath" 116 | fi 117 | 118 | if [ ! -f "$upgradeFile" ]; then 119 | ${sudo_cmd} touch "$upgradeFile" 120 | fi 121 | 122 | ############################################################################### 123 | # Helpers # 124 | ############################################################################### 125 | 126 | ####################################### 127 | # Custom printing function 128 | # Globals: 129 | # None 130 | # Arguments: 131 | # $1 0:OK 1:FAILED 2:INFO 3:NOTICE 132 | # message 133 | # Returns: 134 | # None 135 | ####################################### 136 | 137 | Show() { 138 | # OK 139 | if (($1 == 0)); then 140 | echo -e "- OK $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 141 | # FAILED 142 | elif (($1 == 1)); then 143 | echo -e "- FAILED $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 144 | exit 1 145 | # INFO 146 | elif (($1 == 2)); then 147 | echo -e "- INFO $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 148 | # NOTICE 149 | elif (($1 == 3)); then 150 | echo -e "- NOTICE $2" | ${sudo_cmd} tee -a /var/log/casaos/upgrade.log 151 | fi 152 | } 153 | 154 | Warn() { 155 | echo -e "${aCOLOUR[3]}$1$COLOUR_RESET" 156 | } 157 | 158 | GreyStart() { 159 | echo -e "${aCOLOUR[2]}\c" 160 | } 161 | 162 | ColorReset() { 163 | echo -e "$COLOUR_RESET\c" 164 | } 165 | 166 | # Check file exists 167 | exist_file() { 168 | if [ -e "$1" ]; then 169 | return 1 170 | else 171 | return 2 172 | fi 173 | } 174 | 175 | ############################################################################### 176 | # FUNCTIONS # 177 | ############################################################################### 178 | 179 | # 1 Check Arch 180 | Check_Arch() { 181 | case $UNAME_M in 182 | *aarch64*) 183 | TARGET_ARCH="arm64" 184 | ;; 185 | *riscv64*) 186 | TARGET_ARCH="riscv64" 187 | ;; 188 | *64*) 189 | TARGET_ARCH="amd64" 190 | ;; 191 | *armv7*) 192 | TARGET_ARCH="arm-7" 193 | ;; 194 | *) 195 | Show 1 "Aborted, unsupported or unknown architecture: $UNAME_M" 196 | exit 1 197 | ;; 198 | esac 199 | Show 0 "Your hardware architecture is : $UNAME_M" 200 | CASA_PACKAGES=( 201 | "https://github.com/IceWhaleTech/CasaOS/releases/download/${CASA_TAG}/linux-${TARGET_ARCH}-casaos-${CASA_TAG}.tar.gz" 202 | "https://github.com/IceWhaleTech/CasaOS-Gateway/releases/download/${CASA_TAG}/linux-${TARGET_ARCH}-casaos-gateway-${CASA_TAG}.tar.gz" 203 | "https://github.com/IceWhaleTech/CasaOS-UserService/releases/download/${CASA_TAG}/linux-${TARGET_ARCH}-casaos-user-service-${CASA_TAG}.tar.gz" 204 | "https://github.com/zhanghengxin/CasaOS-UI/releases/download/${CASA_TAG}/linux-all-casaos-${CASA_TAG}.tar.gz" 205 | ) 206 | } 207 | 208 | # 2 Check Distribution 209 | Check_Distribution() { 210 | sType=0 211 | notice="" 212 | case $LSB_DIST in 213 | *debian*) 214 | TARGET_DISTRO="debian" 215 | ;; 216 | *ubuntu*) 217 | TARGET_DISTRO="ubuntu" 218 | ;; 219 | *raspbian*) 220 | TARGET_DISTRO="raspbian" 221 | ;; 222 | *openwrt*) 223 | Show 1 "Aborted, OpenWrt cannot be installed using this script, please visit ${CASA_OPENWRT_DOCS}." 224 | exit 1 225 | ;; 226 | *alpine*) 227 | Show 1 "Aborted, Alpine installation is not yet supported." 228 | exit 1 229 | ;; 230 | *trisquel*) 231 | Target_Distro="debian" 232 | ;; 233 | *) 234 | sType=1 235 | notice="We have not tested it on this system and it may fail to install." 236 | ;; 237 | esac 238 | Show $sType "Your Linux Distribution is : $LSB_DIST $notice" 239 | if [[ $sType == 1 ]]; then 240 | if (whiptail --title "${TITLE}" --yesno --defaultno "Your Linux Distribution is : $LSB_DIST $notice. Continue installation?" 10 60); then 241 | Show 0 "Distribution check has been ignored." 242 | else 243 | Show 1 "Already exited the installation." 244 | exit 1 245 | fi 246 | fi 247 | } 248 | 249 | # 3 Check OS 250 | Check_OS() { 251 | if [[ $UNAME_U == *Linux* ]]; then 252 | TARGET_OS="linux" 253 | Show 0 "Your System is : $UNAME_U" 254 | else 255 | TARGET_OS 1 "This script is only for Linux." 256 | exit 1 257 | fi 258 | } 259 | 260 | # 4 Check Memory 261 | Check_Memory() { 262 | if [[ "${PHYSICAL_MEMORY}" -lt "${MINIMUM_MEMORY}" ]]; then 263 | Show 1 "requires atleast 1GB physical memory." 264 | exit 1 265 | fi 266 | Show 0 "Memory capacity check passed." 267 | } 268 | 269 | # 5 Check Disk 270 | Check_Disk() { 271 | if [[ "${FREE_DISK_GB}" -lt "${MINIMUM_DISK_SIZE_GB}" ]]; then 272 | if (whiptail --title "${TITLE}" --yesno --defaultno "Recommended free disk space is greater than \e[33m${MINIMUM_DISK_SIZE_GB}GB\e[0m, Current free disk space is \e[33m${FREE_DISK_GB}GB.Continue installation?" 10 60); then 273 | Show 0 "Disk capacity check has been ignored." 274 | else 275 | Show 1 "Already exited the installation." 276 | exit 1 277 | fi 278 | else 279 | Show 0 "Disk capacity check passed." 280 | fi 281 | } 282 | 283 | # Check Port Use 284 | Check_Port() { 285 | TCPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l) 286 | UDPListeningnum=$(${sudo_cmd} netstat -an | grep ":$1 " | awk '$1 == "udp" && $NF == "0.0.0.0:*" {print $0}' | wc -l) 287 | ((Listeningnum = TCPListeningnum + UDPListeningnum)) 288 | if [[ $Listeningnum == 0 ]]; then 289 | echo "0" 290 | else 291 | echo "1" 292 | fi 293 | } 294 | 295 | # Update package 296 | 297 | Update_Package_Resource() { 298 | GreyStart 299 | if [ -x "$(command -v apk)" ]; then 300 | ${sudo_cmd} apk update 301 | elif [ -x "$(command -v apt-get)" ]; then 302 | ${sudo_cmd} apt-get update 303 | elif [ -x "$(command -v dnf)" ]; then 304 | ${sudo_cmd} dnf check-update 305 | elif [ -x "$(command -v zypper)" ]; then 306 | ${sudo_cmd} zypper update 307 | elif [ -x "$(command -v yum)" ]; then 308 | ${sudo_cmd} yum update 309 | fi 310 | ColorReset 311 | } 312 | 313 | # Install depends package 314 | Install_Depends() { 315 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 316 | cmd=${CASA_DEPANDS_COMMAND[i]} 317 | if [[ ! -x "$(command -v $cmd)" ]]; then 318 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 319 | Show 2 "Install the necessary dependencies: $packagesNeeded " 320 | GreyStart 321 | if [ -x "$(command -v apk)" ]; then 322 | ${sudo_cmd} apk add --no-cache $packagesNeeded 323 | elif [ -x "$(command -v apt-get)" ]; then 324 | ${sudo_cmd} apt-get -y -q install $packagesNeeded --no-upgrade 325 | elif [ -x "$(command -v dnf)" ]; then 326 | ${sudo_cmd} dnf install $packagesNeeded 327 | elif [ -x "$(command -v zypper)" ]; then 328 | ${sudo_cmd} zypper install $packagesNeeded 329 | elif [ -x "$(command -v yum)" ]; then 330 | ${sudo_cmd} yum install $packagesNeeded 331 | elif [ -x "$(command -v pacman)" ]; then 332 | ${sudo_cmd} pacman -S $packagesNeeded 333 | elif [ -x "$(command -v paru)" ]; then 334 | ${sudo_cmd} paru -S $packagesNeeded 335 | else 336 | Show 1 "Package manager not found. You must manually install: $packagesNeeded" 337 | fi 338 | ColorReset 339 | fi 340 | done 341 | } 342 | 343 | Check_Dependency_Installation() { 344 | for ((i = 0; i < ${#CASA_DEPANDS_COMMAND[@]}; i++)); do 345 | cmd=${CASA_DEPANDS_COMMAND[i]} 346 | if [[ ! -x "$(command -v $cmd)" ]]; then 347 | packagesNeeded=${CASA_DEPANDS_PACKAGE[i]} 348 | Show 1 "Dependency \e[33m$packagesNeeded \e[0m installation failed, please try again manually!" 349 | exit 1 350 | fi 351 | done 352 | } 353 | 354 | 355 | #Configuration Addons 356 | Configuration_Addons() { 357 | Show 2 "Configuration CasaOS Addons" 358 | #Remove old udev rules 359 | if [[ -f $PREFIX/etc/udev/rules.d/11-usb-mount.rules ]]; then 360 | ${sudo_cmd} rm -rf $PREFIX/etc/udev/rules.d/11-usb-mount.rules 361 | fi 362 | 363 | if [[ -f $PREFIX/etc/systemd/system/usb-mount@.service ]]; then 364 | ${sudo_cmd} rm -rf $PREFIX/etc/systemd/system/usb-mount@.service 365 | fi 366 | 367 | #Udevil 368 | if [[ -f $PREFIX${UDEVIL_CONF_PATH} ]]; then 369 | 370 | #Change udevil mount dir to /DATA 371 | ${sudo_cmd} sed -i 's/allowed_media_dirs = \/media\/$USER, \/run\/media\/$USER/allowed_media_dirs = \/DATA, \/DATA\/$USER/g' $PREFIX${UDEVIL_CONF_PATH} 372 | 373 | # GreyStart 374 | # Add a devmon user 375 | USERNAME=devmon 376 | id ${USERNAME} &>/dev/null || { 377 | ${sudo_cmd} useradd -M -u 300 ${USERNAME} 378 | ${sudo_cmd} usermod -L ${USERNAME} 379 | } 380 | 381 | # Add and start Devmon service 382 | GreyStart 383 | ${sudo_cmd} systemctl enable devmon@devmon 384 | ${sudo_cmd} systemctl start devmon@devmon 385 | ColorReset 386 | # ColorReset 387 | fi 388 | } 389 | 390 | # Download And Install CasaOS 391 | DownloadAndInstallCasaOS() { 392 | # Get the latest version of CasaOS 393 | if [[ ! -n "$version" ]]; then 394 | CASA_TAG="v$(${NET_GETTER} ${CASA_VERSION_URL})" 395 | elif [[ $version == "pre" ]]; then 396 | CASA_TAG="$(${NET_GETTER} ${CASA_RELEASE_API} | grep -o '"tag_name": ".*"' | sed 's/"//g' | sed 's/tag_name: //g' | sed -n '1p')" 397 | else 398 | CASA_TAG="$version" 399 | fi 400 | 401 | if [ -z "${BUILD_DIR}" ]; then 402 | 403 | ${sudo_cmd} mkdir -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory" 404 | TMP_DIR=$(mktemp -d -p ${TMP_ROOT} || Show 1 "Failed to create temporary directory") 405 | 406 | pushd "${TMP_DIR}" 407 | 408 | for PACKAGE in "${CASA_PACKAGES[@]}"; do 409 | Show 2 "Downloading ${PACKAGE}..." 410 | 411 | ${sudo_cmd} curl -sLO "${PACKAGE}" || Show 1 "Failed to download package" 412 | 413 | done 414 | 415 | for PACKAGE_FILE in linux-*-casaos-*.tar.gz; do 416 | Show 2 "Extracting ${PACKAGE_FILE}..." 417 | ${sudo_cmd} tar zxf "${PACKAGE_FILE}" || Show 1 "Failed to extract package" 418 | done 419 | 420 | BUILD_DIR=$(realpath -e "${TMP_DIR}"/build || Show 1 "Failed to find build directory") 421 | 422 | popd 423 | fi 424 | 425 | # for SERVICE in "${CASA_SERVICES[@]}"; do 426 | # Show 2 "Stopping ${SERVICE}..." 427 | 428 | # systemctl stop "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 429 | 430 | # done 431 | 432 | MIGRATION_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/migration/script.d || Show 1 "Failed to find migration script directory") 433 | 434 | for MIGRATION_SCRIPT in "${MIGRATION_SCRIPT_DIR}"/*.sh; do 435 | Show 2 "Running ${MIGRATION_SCRIPT}..." 436 | 437 | ${sudo_cmd} bash "${MIGRATION_SCRIPT}" || Show 1 "Failed to run migration script" 438 | 439 | done 440 | 441 | Show 2 "Installing CasaOS..." 442 | SYSROOT_DIR=$(realpath -e "${BUILD_DIR}"/sysroot || Show 1 "Failed to find sysroot directory") 443 | 444 | # Generate manifest for uninstallation 445 | MANIFEST_FILE=${BUILD_DIR}/sysroot/var/lib/casaos/manifest 446 | ${sudo_cmd} touch "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 447 | 448 | 449 | find "${SYSROOT_DIR}" -type f | ${sudo_cmd} cut -c ${#SYSROOT_DIR}- | ${sudo_cmd} cut -c 2- | ${sudo_cmd} tee "${MANIFEST_FILE}" || Show 1 "Failed to create manifest file" 450 | 451 | ${sudo_cmd} cp -rf "${SYSROOT_DIR}"/* / >> /dev/null || Show 1 "Failed to install CasaOS" 452 | 453 | SETUP_SCRIPT_DIR=$(realpath -e "${BUILD_DIR}"/scripts/setup/script.d || Show 1 "Failed to find setup script directory") 454 | 455 | for SETUP_SCRIPT in "${SETUP_SCRIPT_DIR}"/*.sh; do 456 | Show 2 "Running ${SETUP_SCRIPT}..." 457 | ${sudo_cmd} bash "${SETUP_SCRIPT}" || Show 1 "Failed to run setup script" 458 | done 459 | 460 | #Download Uninstall Script 461 | if [[ -f $PREFIX/tmp/casaos-uninstall ]]; then 462 | ${sudo_cmd} rm -rf $PREFIX/tmp/casaos-uninstall 463 | fi 464 | ${sudo_cmd} curl -fsSLk "$CASA_UNINSTALL_URL" >"$PREFIX/tmp/casaos-uninstall" 465 | ${sudo_cmd} cp -rvf "$PREFIX/tmp/casaos-uninstall" $CASA_UNINSTALL_PATH 466 | if [[ $? -ne 0 ]]; then 467 | Show 1 "Download uninstall script failed, Please check if your internet connection is working and retry." 468 | exit 1 469 | fi 470 | ${sudo_cmd} chmod +x $CASA_UNINSTALL_PATH 471 | 472 | ## Special markings 473 | 474 | Show 0 "CasaOS upgrade successfully" 475 | for SERVICE in "${CASA_SERVICES[@]}"; do 476 | Show 2 "restart ${SERVICE}..." 477 | 478 | ${sudo_cmd} systemctl restart "${SERVICE}" || Show 3 "Service ${SERVICE} does not exist." 479 | 480 | done 481 | 482 | 483 | } 484 | 485 | ############################################################################### 486 | # Main # 487 | ############################################################################### 488 | 489 | #Usage 490 | usage() { 491 | cat <<-EOF 492 | Usage: get.sh [options] 493 | Valid options are: 494 | -v Specify version to install For example: get.sh -v v0.2.3 | get.sh -v pre | get.sh 495 | -p Specify build directory 496 | -h Show this help message and exit 497 | EOF 498 | exit $1 499 | } 500 | 501 | while getopts ":v:p:h" arg; do 502 | case "$arg" in 503 | v) 504 | version=$OPTARG 505 | ;; 506 | p) 507 | BUILD_DIR=$OPTARG 508 | ;; 509 | h) 510 | usage 0 511 | ;; 512 | esac 513 | done 514 | 515 | # Step 1:Check ARCH 516 | Check_Arch 517 | 518 | # Step 2: Check OS 519 | Check_OS 520 | 521 | # Step 3: Check Distribution 522 | Check_Distribution 523 | 524 | # Step 4: Check System 525 | Check_Memory 526 | 527 | # Step 5: Install Depends 528 | # Update_Package_Resource 529 | Install_Depends 530 | Check_Dependency_Installation 531 | 532 | # Step 7: Configuration Addon 533 | Configuration_Addons 534 | 535 | # Step 8: Download And Install CasaOS 536 | DownloadAndInstallCasaOS 537 | --------------------------------------------------------------------------------