#!/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin; module_dir="/root/amh/modules/AMProxy-2.0/"; #info function amh_module_info() { echo 'AMH-ModuleName: AMProxy-2.0'; echo 'AMH-ModuleDescription: AMProxy-2.0 反向代理模块修改版(用于API兼容HYProxy)'; echo 'AMH-ModuleButton: 安装/卸载'; echo 'AMH-ModuleDate: 2020-01-17'; echo 'AMH-ModuleAdmin: ./index.php?c=amproxy'; echo 'AMH-ModuleWebSite: http://www.huayizhiyun.com'; echo 'AMH-ModuleScriptBy: HITSword.'; } #install function amh_module_install() { if amh_module_status ; then exit; else if [ ! -f "/root/amh/modules/HYProxy-1.0/InstallComplete" ]; then echo '[Error] HYProxy 未安装.'; exit; fi; cd /root/amh/modules/AMProxy-2.0; touch ./InstallComplete; amh_module_status; fi; } #uninstall function amh_module_uninstall() { if amh_module_status ; then rm -f /root/amh/modules/AMProxy-2.0/InstallComplete; echo '[OK] AMProxy-2.0 Uninstall successful.'; else exit; fi; } #admin function amh_module_admin() { if amh_module_status ; then param_list=${1//,/ }; set -- $param_list; action=$1; domain=$2; if [ "$action" == '' ]; then echo "[Notice] AMProxy management, please select: (1~4)" select action in 'list' 'add' 'start' 'stop' 'edit' 'del' 'start-cache' 'stop-cache' 'cache' 'cache-index' 'cache-delete'; do break; done; fi; case $action in list) php ${module_dir}cli.php --action='list'; ;; start) echo "start something"; ;; stop) echo "stop something"; ;; add) proxy_pass=$3; php ${module_dir}cli.php --action='add' --server_name=${domain} --proxy_pass=${proxy_pass}; amh nginx reload; ;; edit) ParamName=$3 ParamVal=$4 php ${module_dir}cli.php --action='edit' --server_name=${domain} --field_name=${ParamName} --value=${ParamVal}; amh nginx reload; ;; del) echo "del something"; ;; start-cache) echo "start cache"; ;; stop-cache) echo "stop cache"; ;; cache) echo "[Notice] 暂不支持缓存配置"; ;; cache-index) echo "[Notice] 暂不支持缓存索引"; ;; cache-delete) echo "[Notice] 暂不支持缓存删除"; ;; *) echo "[Notice] 无效操作"; ;; esac else exit; fi; } #status function amh_module_status() { if [ -f "/root/amh/modules/AMProxy-2.0/InstallComplete" ]; then echo '[OK] AMProxy-2.0 is already installed.'; return 0; else echo '[Notice] AMProxy-2.0 is not installed.'; return 1; fi; }