#!/bin/bash export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.acepanel.net/public.sh) if [ $? -ne 0 ]; then echo "Download public.sh failed, please check the network or try again later." exit 1 fi channel=${1} version=${2} code_server_path="${setup_path}/server/code-server" if [ ! -d "${code_server_path}" ]; then mkdir -p ${code_server_path} fi # 架构判断 if [ ${ARCH} == "x86_64" ]; then code_server_file="code-server-${version}-linux-amd64.7z" elif [ ${ARCH} == "aarch64" ]; then code_server_file="code-server-${version}-linux-arm64.7z" else error "Unsupported architecture" fi # 下载 cd ${code_server_path} dl "${code_server_path}" "/code-server/${code_server_file}" # 解压 cd ${code_server_path} 7z x ${code_server_file} rm -f ${code_server_file} if [ ! -f "${code_server_path}/bin/code-server" ]; then rm -rf ${code_server_path} error "code-server extraction failed" fi # 初始化目录 chown -R root:root ${code_server_path} chmod -R 700 ${code_server_path} ln -sf ${code_server_path}/bin/code-server /usr/local/bin/code-server # 写入配置 password=$(cat /dev/urandom | head -n 16 | sha256sum | head -c 16) cat >/root/.config/code-server/config.yaml </etc/systemd/system/code-server.service <