diff options
author | taotieren | 2025-03-12 17:50:41 +0800 |
---|---|---|
committer | taotieren | 2025-03-12 17:50:41 +0800 |
commit | 36183d241c1e6483394db6f86149cd3bd5c14e6c (patch) | |
tree | f16b4d749144f6d20ec110f6ce612f40ceadeaf5 | |
parent | 6cacfdc88f537da5f7103e7e1f1236922d252579 (diff) | |
download | aur-36183d241c1e6483394db6f86149cd3bd5c14e6c.tar.gz |
[lilac] updated to 1.10.27.lts.r1.g617970a-2
-rw-r--r-- | .SRCINFO | 15 | ||||
-rw-r--r-- | 1panel.install | 87 | ||||
-rw-r--r-- | 1panel.service | 18 | ||||
-rw-r--r-- | 1pctl | 204 | ||||
-rw-r--r-- | PKGBUILD | 110 |
5 files changed, 325 insertions, 109 deletions
@@ -1,23 +1,32 @@ pkgbase = 1panel-git pkgdesc = 1Panel, a modern open source linux panel. - pkgver = 2024.3.9.archlinux - pkgrel = 1 + pkgver = 1.10.27.lts.r1.g617970a + pkgrel = 2 url = https://1panel.cn install = 1panel.install arch = x86_64 arch = aarch64 license = GPL-3.0-or-later - makedepends = pwgen makedepends = go makedepends = nodejs makedepends = git + makedepends = npm + makedepends = python + depends = glibc + depends = sh optdepends = ufw optdepends = firewalld optdepends = docker optdepends = docker-compose + provides = 1panel + conflicts = 1panel conflicts = 1panel-dev-bin conflicts = 1panel-bin source = 1panel-git::git+https://github.com/1Panel-dev/1Panel.git + source = 1pctl + source = 1panel.service sha256sums = SKIP + sha256sums = b10ccbfe7055854185cb2cbcaff60774bfd6105e90780ffd0a3a5a2980c5696d + sha256sums = 4763d661d985228b99b9be12ef8140c63c14e6cf40a07411db8e32d9a73cae42 pkgname = 1panel-git diff --git a/1panel.install b/1panel.install index aacd4195c02f..7721fd338086 100644 --- a/1panel.install +++ b/1panel.install @@ -1,76 +1,49 @@ +#!/bin/bash + pre_install() { - echo -e "================== installing 1Panel ==================" + echo -e "==================== 准备安装 1Panel ====================" + # 判断/var/lib/1p是否存在 + if [ -d "/var/lib/1p/1panel" ]; then + echo -e "\033[32m警告: \033[0m/var/lib/1p/1panel 目录已存在,可能会影响 1Panel 的初始化。" + fi } post_install() { - echo -e "Obtaining the local IP address of this machine..." - _1panel_active_interface=$(ip route get 8.8.8.8 | awk 'NR==1 {print $5}') - if [[ -z $_1panel_active_interface ]]; then - _1panel_local_ip="127.0.0.1" - else - _1panel_local_ip=`ip -4 addr show dev "$_1panel_active_interface" | grep -oP '(?<=inet\s)\d+(\.\d+){3}'` - fi - echo -e "Obtaining the public IP address of this machine..." - _1panel_public_ip=`curl -s https://api64.ipify.org` - if [[ -z "$_1panel_public_ip" ]]; then - _1panel_public_ip="N/A" - fi - if echo "$_1panel_public_ip" | grep -q ":"; then - _1panel_public_ip=[${_1panel_public_ip}] - 1panel listen-ip ipv6 - fi - if [ $_1panel_public_ip == "N/A" ]; then - echo -e "\033[31mFailed to get 1Panel public IP address.\033[0m" - fi - # ORIGINAL_PORT=port (/usr/bin/1pctl) - _1panel_port=$(sed -n 's/^ORIGINAL_PORT=\(.*\)/\1/p' /usr/bin/1pctl) - _1panel_username=$(sed -n 's/^ORIGINAL_USERNAME=\(.*\)/\1/p' /usr/bin/1pctl) - _1panel_password=$(sed -n 's/^ORIGINAL_PASSWORD=\(.*\)/\1/p' /usr/bin/1pctl) - _1panel_entrance=$(sed -n 's/^ORIGINAL_ENTRANCE=\(.*\)/\1/p' /usr/bin/1pctl) - echo -e "================== 1Panel installed ===================" - echo -e "Please access 1Panel using your web browser after the \033[33m 1panel.service\033[0m service is started." - echo -e "Local IP: http://$_1panel_local_ip:$_1panel_port/$_1panel_entrance" - echo -e "Public IP: http://$_1panel_public_ip:$_1panel_port/$_1panel_entrance" - echo -e "Username: $_1panel_username" - echo -e "Password: $_1panel_password" - echo -e "If you are not Chinese user, please click \033[32m'中文(简体)'\033[0m and switch it to English." - # 判断docker和docker-compose安装 + # Detecting if docker and docker-compose are successfully installed. if pacman -Qs docker >/dev/null 2>&1; then - echo -e "\033[32mDocker is installed correctly.\033[0m" + echo -e "\033[32mDocker 已成功安装.\033[0m" else - echo -e "\033[31mWarning: Docker is not installed, please install it, or most of the features of this package will not be available.\033[0m" + echo -e "\033[33m警告: Docker 未安装,请安装它,否则 1Panel 的大部分服务将无法使用。\033[0m" fi if pacman -Qs docker-compose >/dev/null 2>&1; then - echo -e "\033[32mDocker Compose is installed correctly.\033[0m" + echo -e "\033[32mDocker-compose 已成功安装。\033[0m" else - echo -e "\033[31mWarning: Docker Compose is not installed, please install it, or 1Panel application store will not be avaliable.\033[0m" + echo -e "\033[33m警告: docker-compose 未安装,请安装它,否则 1Panel 应用商店将无法使用。\033[0m" fi - unset _1panel_active_interface - unset _1panel_local_ip - unset _1panel_public_ip - unset _1panel_port - unset _1panel_username - unset _1panel_password - unset _1panel_entrance + echo -e "\033[31m使用默认的用户名和密码将是一个十分危险的行为!!!\033[0m." + echo -e "请务必在启动 \033[34m1panel.service\033[0m 之前运行 \033[34m1pctl init\033[0m 来设置您的用户名和密码!" + echo -e "" + echo -e "==================== 1Panel 安装完成 ====================" } pre_remove() { - echo -e "================== Uninstalling 1Panel ==================" - echo -e "\033[34mStopping systemd service...\033[0m" + echo -e "==================== 准备卸载 1Panel ====================" + echo -e "\033[34m正在停止 systemd 服务...\033[0m" systemctl disable --now 1panel } post_remove() { - echo -e "\033[34mPlease delete /opt/1panel files after backup them...\033[0m" - echo -e "=================== 1Panel uninstalled ==================" + echo -e "请手动备份 \033[34m/var/lib/1p/1panel\033[0m 目录后删除它。" + echo -e "==================== 1Panel 卸载完成 ====================" } pre_upgrade() { export no_need_start="false" - echo -e "================== Upgrading 1Panel ===================" - # Stop 1panel service` + echo -e "==================== 准备更新 1Panel ====================" + echo -e " 正在备份1pctl文件" + cp /usr/bin/1pctl /usr/bin/1pctl.bak if systemctl is-active --quiet 1panel; then - echo -e "Temporarily stoping 1Panel service..." + echo -e "检测到systemd服务正在运行,正在临时停止 1Panel 服务..." systemctl stop 1panel export _restart_1panel_service=true fi @@ -79,9 +52,17 @@ pre_upgrade() { post_upgrade() { if [ -n "${_restart_1panel_service+x}" ]; then - echo -e "Restarting..." + echo -e "正在重启服务..." systemctl start 1panel unset _restart_1panel_service + systemctl daemon-reload fi - echo -e "=================== 1Panel upgraded ===================" + # 提取1pctl的ORIGINAL_VERSION变量的值 + _1panel_version=$(grep -oP '(?<=ORIGINAL_VERSION=).*' /usr/bin/1pctl) + echo -e "正在恢复1pctl备份" + mv /usr/bin/1pctl.bak /usr/bin/1pctl + # 更新1pctl的ORIGINAL_VERSION变量的值 + sed -i -e "s#ORIGINAL_VERSION=.*#ORIGINAL_VERSION=${_1panel_version}#g" /usr/bin/1pctl + chmod 755 /usr/bin/1pctl + echo -e "==================== 1Panel 更新完成 ====================" } diff --git a/1panel.service b/1panel.service new file mode 100644 index 000000000000..a20b624b3332 --- /dev/null +++ b/1panel.service @@ -0,0 +1,18 @@ +[Unit] +Description=1Panel, a modern open source linux panel +After=syslog.target network-online.target +Wants=network-online.target + +[Service] +ExecStart=/usr/bin/1panel +ExecReload=/bin/kill -s HUP $MAINPID +Restart=always +RestartSec=5 +LimitNOFILE=1048576 +LimitNPROC=1048576 +LimitCORE=1048576 +Delegate=yes +KillMode=process + +[Install] +WantedBy=multi-user.target diff --git a/1pctl b/1pctl new file mode 100644 index 000000000000..fb9231eaa311 --- /dev/null +++ b/1pctl @@ -0,0 +1,204 @@ +#!/bin/bash + +action=$1 +target=$2 +args=$@ + +BASE_DIR=/var/lib/1p +ORIGINAL_PORT=8888 +ORIGINAL_VERSION=v1.10.26-lts +ORIGINAL_ENTRANCE=entrance +ORIGINAL_USERNAME=username +ORIGINAL_PASSWORD=password +LANGUAGE=en + +if [ -f "/usr/local/bin/lang/$LANGUAGE.sh" ]; then + source "/usr/local/bin/lang/$LANGUAGE.sh" +else + LANGUAGE=en +fi + +function usage() { + echo "$PANEL_CONTROL_SCRIPT" + echo + echo "Usage: " + echo " ./1pctl [COMMAND] [ARGS...]" + echo " ./1pctl --help" + echo + echo "Commands: " + echo " status $TXT_PANEL_SERVICE_STATUS" + echo " start $TXT_PANEL_SERVICE_START" + echo " stop $TXT_PANEL_SERVICE_STOP" + echo " restart $TXT_PANEL_SERVICE_RESTART" + echo " uninstall $TXT_PANEL_SERVICE_UNINSTALL" + echo " user-info $TXT_PANEL_SERVICE_USER_INFO" + echo " listen-ip $TXT_PANEL_SERVICE_LISTEN_IP" + echo " version $TXT_PANEL_SERVICE_VERSION" + echo " update $TXT_PANEL_SERVICE_UPDATE" + echo " reset $TXT_PANEL_SERVICE_RESET" + echo " restore $TXT_PANEL_SERVICE_RESTORE" +} + +function status() { + systemctl status 1panel.service +} + +function start() { + systemctl start 1panel.service + status +} + +function stop() { + systemctl stop 1panel.service + status +} + +function restart() { + systemctl restart 1panel.service + status +} + +function uninstall() { + read -p "$TXT_PANEL_SERVICE_UNINSTALL_NOTICE : " yn + if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then + echo -e "$TXT_PANEL_SERVICE_UNINSTALL_START" + systemctl stop 1panel.service + systemctl disable 1panel.service >/dev/null 2>&1 + echo -e "$TXT_PANEL_SERVICE_UNINSTALL_REMOVE" + rm -rf $BASE_DIR/1panel /usr/local/bin/{1pctl,1panel} /etc/systemd/system/1panel.service + systemctl daemon-reload + systemctl reset-failed + echo -e "$TXT_PANEL_SERVICE_UNINSTALL_SUCCESS" + else + exit 0 + fi +} + +function user-info() { + 1panel -l $LANGUAGE user-info +} + +function listen-ip() { + case "${target}" in + ipv4) + 1panel -l $LANGUAGE listen-ip ipv4 + restart + ;; + ipv6) + 1panel -l $LANGUAGE listen-ip ipv6 + restart + ;; + *) + 1panel -l $LANGUAGE listen-ip + ;; + esac +} + +function restore() { + read -p "$TXT_PANEL_SERVICE_RESTORE_NOTICE : " yn + if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then + 1panel -l $LANGUAGE restore + systemctl daemon-reload + restart + 1panel -l $LANGUAGE version + else + exit 0 + fi +} + +function version() { + 1panel -l $LANGUAGE version +} + +function reset() { + case "${target}" in + domain) + 1panel -l $LANGUAGE reset domain + ;; + entrance) + 1panel -l $LANGUAGE reset entrance + ;; + https) + 1panel -l $LANGUAGE reset https + restart + ;; + ips) + 1panel -l $LANGUAGE reset ips + ;; + mfa) + 1panel -l $LANGUAGE reset mfa + ;; + *) + 1panel -l $LANGUAGE reset + ;; + esac +} + +function update() { + case "${target}" in + username) + 1panel -l $LANGUAGE update username + ;; + password) + 1panel -l $LANGUAGE update password + ;; + port) + 1panel -l $LANGUAGE update port + ;; + *) + 1panel -l $LANGUAGE update + ;; + esac +} + +function main() { + case "${action}" in + status) + status + ;; + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + restore) + restore + ;; + uninstall) + uninstall + ;; + user-info) + user-info + ;; + listen-ip) + listen-ip + ;; + version) + version + ;; + reset) + reset + ;; + update) + update + ;; + help) + usage + ;; + --help) + usage + ;; + "") + usage + ;; + *) + echo "$TXT_PANEL_SERVICE_UNSUPPORTED_PARAMETER" + ;; + esac +} + +main @@ -1,82 +1,86 @@ # Maintainer: Senge Dev <sengedev at gmail dot com> +# Maintainer: taotieren <admin@taotieren.com> # Contributor: Senge Dev <sengedev at gmail dot com> pkgname=1panel-git -pkgver=2024.3.9.archlinux -pkgrel=1 +pkgver=1.10.27.lts.r1.g617970a +pkgrel=2 pkgdesc="1Panel, a modern open source linux panel." arch=('x86_64' 'aarch64') url="https://1panel.cn" license=('GPL-3.0-or-later') install=1panel.install +depends=( + glibc + sh +) makedepends=( - 'pwgen' # Generate username, password and 1Panel entrance before compile. - 'go' # Compile the backend of 1Panel. - 'nodejs' # Compile the frontend of 1Panel. - 'git' # Clone the 1Panel repository. - 'lsof' # Make sure the port will not be occupied. + go + nodejs + git + npm + python ) optdepends=( - 'ufw' # Firewall manager - 'firewalld' # Firewall manager - 'docker' # Docker image manager - 'docker-compose' # Docker compose plugin, make sure 1Panel app store works. + 'ufw' # Firewall manager + 'firewalld' # Firewall manager + 'docker' # Docker image manager + 'docker-compose' # Docker compose plugin, make sure 1Panel app store works. ) +provides=(${pkgname%-git}) conflicts=( + ${pkgname%-git} '1panel-dev-bin' '1panel-bin' ) -source=("${pkgname}"::"git+https://github.com/1Panel-dev/1Panel.git") -sha256sums=("SKIP") +source=("${pkgname}"::"git+https://github.com/1Panel-dev/1Panel.git" + "1pctl" + "1panel.service" +) +sha256sums=('SKIP' + 'b10ccbfe7055854185cb2cbcaff60774bfd6105e90780ffd0a3a5a2980c5696d' + '4763d661d985228b99b9be12ef8140c63c14e6cf40a07411db8e32d9a73cae42') -build() { - _1panel_port=`expr $RANDOM % 55535 + 10000` - while lsof -i:$_1panel_port > /dev/null 2>&1; do - _1panel_port=`expr $RANDOM % 55535 + 10000` - done - # Create 1pctl file, or 1Panel systemd service cannot start. - cat > ${srcdir}/1pctl << EOF -#!/bin/bash -BASE_DIR=/opt -ORIGINAL_PORT=${_1panel_port} -ORIGINAL_VERSION=${pkgver} -ORIGINAL_ENTRANCE=$(pwgen -nABCv 10 1) -ORIGINAL_USERNAME=$(pwgen -nABCv 10 1) -ORIGINAL_PASSWORD=$(pwgen -nBCv 20 1) -1panel \$@ -EOF - # Create systemd service - cat> ${srcdir}/1panel.service << EOF -[Unit] -Description=1Panel, a modern open source linux panel -After=syslog.target network.target +pkgver() { + cd "${srcdir}/${pkgname}" + ( + set -o pipefail + git describe --long --tag --abbrev=7 2>/dev/null | sed 's/^v//g;s/\([^-]*-g\)/r\1/;s/-/./g' || + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)" + ) +} -[Service] -ExecStart=/usr/bin/1panel -ExecReload=/bin/kill -s HUP \$MAINPID -Restart=always -RestartSec=5 -LimitNOFILE=1048576 -LimitNPROC=1048576 -LimitCORE=1048576 -Delegate=yes -KillMode=process +build() { + sed -i -e "s#ORIGINAL_VERSION=.*#ORIGINAL_VERSION=${pkgver}#g" ${srcdir}/1pctl + find ${srcdir} -type f -exec sed -i 's@/usr/local/bin@/usr/bin@g' {} + + find ${srcdir} -type f -exec sed -i 's@/etc/systemd/system@/usr/lib/systemd/system@g' {} + -[Install] -WantedBy=multi-user.target -EOF # Edit the source code using sed - sed -i 's/当前已经是最新版本/当前版本为AUR版本,如需更新,请使用AUR更新/g' ${srcdir}/${pkgname}/frontend/src/lang/modules/zh.ts - sed -i 's/當前已經是最新版本/當前版本為AUR版本,如需更新,請使用AUR更新/g' ${srcdir}/${pkgname}/frontend/src/lang/modules/tw.ts + sed -i 's/当前已经是最新版本/当前版本为 AUR 版本,如需更新,请使用 AUR 更新/g' ${srcdir}/${pkgname}/frontend/src/lang/modules/zh.ts + sed -i 's/當前已經是最新版本/當前版本為 AUR 版本,如需更新,請使用 AUR 更新/g' ${srcdir}/${pkgname}/frontend/src/lang/modules/tw.ts sed -i 's/It is currently the latest version/It is ArchLinux AUR version, if you want to update it, please use AUR./g' ${srcdir}/${pkgname}/frontend/src/lang/modules/en.ts - # Compile 1Panel using Makefile - cd ${srcdir}/${pkgname} - make build_all + + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" + export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" + export GO111MODULE=on + export GOPROXY=https://goproxy.cn,direct + + export NODE_OPTIONS="--max-old-space-size=4096" + + cd ${srcdir}/${pkgname}/frontend + npm install + npm rum build:pro + cd ${srcdir}/${pkgname}/backend + GOOS=linux GOARCH=$(go env GOARCH) go build -trimpath -ldflags '-s -w' -o ${srcdir}/${pkgname}//build/1panel ${srcdir}/${pkgname}/cmd/server/main.go } package() { - install -vd ${pkgdir}/opt/1panel + install -vd ${pkgdir}/var/lib/1p/1panel install -vDm755 ${srcdir}/${pkgname}/build/1panel ${pkgdir}/usr/bin/1panel install -vDm644 ${srcdir}/1panel.service -t ${pkgdir}/usr/lib/systemd/system install -vDm755 ${srcdir}/1pctl ${pkgdir}/usr/bin/1pctl + install -vDm644 ${srcdir}/${pkgname}/LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/" } |