diff --git a/.gitignore b/.gitignore index aa81eed..f3ae036 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +*.part *.deb *.pkg.* diff --git a/PKGBUILD b/PKGBUILD index 334b5d0..c083672 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -6,12 +6,15 @@ pkgdesc="ChinaTelecom AOne (${_pkgname}) VPN" arch=(x86_64) url="https://aone.ctyun.cn/h5/ct0trust/index.html#/terminalManage/clientDownload?key=C4C330843B2111C9EE134125AF2C43FE" license=(EULA) -depends=('libxtst' 'nss' 'iptables-nft') +depends=(libxtst nss iptables-nft) install=${_pkgname}.install source=('https://soc-0trust.ctcdn.cn/client/20250924002450-AOne-2.22.2-Ubuntu-X64-release-20250902152242.deb') sha256sums=('1d091e26632c29e48ca7fefa563d1ce491e4cb45497ea02b32defad47c199e60') package(){ - tar -xf data.tar.xz -C "${pkgdir}" + tar -xf data.tar.xz -C ${pkgdir}/ + mkdir ${pkgdir}/opt/AOne/control-scripts/ + tar -xf control.tar.gz -C ${pkgdir}/opt/AOne/control-scripts/ + chmod +x ${pkgdir}/opt/AOne/control-scripts/* } diff --git a/access-one.install b/access-one.install index 3e3c197..c17a534 100644 --- a/access-one.install +++ b/access-one.install @@ -1,100 +1,36 @@ -pre_install(){ - echo 'before install script executing...' - - programDir="/opt/AOne" - processName="AOne" +stop_process(){ echo "checking running process..." - # 检查进程是否存在 + processName="AOne" if pgrep -x "$processName" >/dev/null; then echo "$processName is running,stopping..." - # 终止进程 killall -e $processName fi - - echo 'before install script complete' } - - -post_install(){ - echo 'after install script executing...' - - programDir="/opt/AOne" - - # 解决Ubuntu 24.04上启动时的sandbox权限报错 - sudo chown root ${programDir}/chrome-sandbox - sudo chmod 4755 ${programDir}/chrome-sandbox - - sudo chmod +x ${programDir}/resources/bin/ctEAO - sudo cp ${programDir}/resources/bin/aone.service /etc/systemd/system - - sudo systemctl daemon-reload - - sudo systemctl enable aone.service - sudo systemctl start aone.service - - # 写入包的类型,用于更新时判断当前包的类型以从平台上获取更新 - sudo echo "deb" > ${programDir}/pkg-type - echo 'after install script complete' -} - - -pre_remove(){ - echo 'before remove script executing...' - - programDir="/opt/AOne" - processName="AOne" - echo "checking running process..." - # 检查进程是否存在 - if pgrep -x "$processName" >/dev/null; then - echo "$processName is running, stopping..." - # 终止进程 - killall -e $processName - fi - - # 卸载 - if [ "$1" = "remove" ]; then - # 拷贝cps-agent的卸载脚本到tmp目录 - if [ -f "${programDir}/resources/bin/uninst_cps.sh" ]; then - cp -f ${programDir}/resources/bin/uninst_cps.sh /tmp/uninst_cps.sh 2>/dev/null - fi - - # 生成卸载标志文件 - flagFile="${programDir}/resources/bin/uninstallflag.log" - if [ ! -f $flagFile ]; then - touch $flagFile - fi - fi - - echo 'before remove script complete' -} - - -post_remove(){ - echo 'after remove script executing...' - - programDir="/opt/AOne" - - num=`systemctl status aone|grep "Active"|grep "running"|wc -l` +stop_service(){ + echo "checking running service..." + serviceName="aone.service" + num=`systemctl status $serviceName|grep "Active"|grep "running"|wc -l` if [ $num -ne 0 ]; then - sudo systemctl stop aone.service - sudo systemctl disable aone.service + echo "$serviceName is running,stopping..." + systemctl stop $serviceName + systemctl disable $serviceName fi +} - if [ -f /etc/systemed/system/aone.service ]; then - sudo rm -rf /etc/systemd/system/aone.service - fi - - # 卸载信创主机安全 - if [ "$1" = "remove" ]; then - uninst_script_path="/tmp/uninst_cps.sh" - bash_path=$(command -v bash 2>/dev/null) - if [ $? -eq 0 ] && [ -f "$uninst_script_path" ]; then - nohup "$bash_path" $uninst_script_path >/dev/null 2>&1 & - else - sudo systemctl stop cps-agent 2>/dev/null - sudo systemctl disable cps-agent 2>/dev/null - fi - fi - - echo 'after remove script complete' +pre_install(){ + stop_service + stop_process +} +post_install(){ + bash /opt/AOne/control-scripts/postinst +} +pre_remove(){ + bash /opt/AOne/control-scripts/prerm + bash /opt/AOne/control-scripts/postrm +} +post_remove(){ + stop_service + stop_process + rm -rf /etc/systemd/system/aone.service + rm -rf /opt/AOne } \ No newline at end of file