diff --git a/packageship/packageship/pkgshipd b/packageship/packageship/pkgshipd index 27530abca7349bf46d4f7d45cd63f1a2cc4fe8fe..fef39e39e3eff2b472a447d3dc428b393574b61a 100755 --- a/packageship/packageship/pkgshipd +++ b/packageship/packageship/pkgshipd @@ -10,6 +10,14 @@ if [ ! -f "$SYS_PATH/package.ini" ]; then exit 0 fi +user=$(id | awk '{print $2}' | cut -d = -f 2) +if [ "$user" == "0(root)" ]; then + echo "[INFO] Current user is root" +else + echo "[ERROR] Current user is not root, the service don't support common user." + exit 1 +fi + function check_config_file(){ echo "[INFO] Check validation of config file." check_null @@ -24,13 +32,16 @@ function check_config_file(){ echo "[INFO] IP addresses are all valid." echo "[INFO] Check validation of numbers." - hour=$(get_config "$service" "hour") - minute=$(get_config "$service" "minute") - backup_count=$(get_config "$service" "backup_count") - max_bytes=$(get_config "$service" "max_bytes") - check_num $hour "hour" - check_num $backup_count "backup_count" - check_num $max_bytes "max_bytes" + num_vars=(backup_count max_bytes buffer-size http-timeout harakiri hour minute pool_workers) + for var in ${num_vars[@]} + do + value=$(get_config "$service" $var) + if [[ -z "$value" ]]; then + echo "[ERROR] CAN NOT find config name $var in: $SYS_PATH/package.ini, Please check the file." + exit 1 + fi + check_num ${value} ${var} + done echo "[INFO] All numbers are valid." echo "[INFO] Check validation of words." @@ -53,9 +64,10 @@ function check_addr(){ ret=$? fi if [ $ret -ne 0 ]; then - echo "[ERROR] Invaild ip of $1" + echo "[ERROR] Invalid ip of $1" exit 1 fi + check_num $2 "port" if [[ $2 -gt 65534 || $2 -lt 1025 ]]; then echo "[ERROR] Invalid port of $2" exit 1 @@ -69,8 +81,8 @@ function check_null(){ do num=$[$num+1] done - if [ $num -gt 1 ]; then - echo "[ERROR] CAN NOT find all config name in: $SYS_PATH/package.ini, Please check the file:" + if [ $num -gt 0 ]; then + echo "[ERROR] The value of below config names is None in: $SYS_PATH/package.ini, Please check these parameters:" for val in $list do echo $val @@ -88,13 +100,14 @@ function check_num(){ } function check_word(){ - result=`echo $1 | grep -E "$2"` + result=`echo $1 | grep -wE "$2"` if [ $? -ne 0 ]; then echo "[ERROR] $3 should be $2." exit 1 fi } + function get_config(){ cat $SYS_PATH/package.ini | grep -E ^$2 | sed s/[[:space:]]//g | awk 'BEGIN{FS="="}{print $2}' } @@ -105,8 +118,8 @@ function create_config_file(){ buffer_size=$(get_config "$service" "buffer-size") http_timeout=$(get_config "$service" "http-timeout") harakiri=$(get_config "$service" "harakiri") - wsgi_file_path=$(find /usr/lib/ -name "packageship" | head -n 1) - echo "[INFO] run packageship under path: $wsgi_file_path" + uwsgi_file_path=$(find /usr/lib/ -name "packageship" | head -n 1) + echo "[INFO] run packageship under path: $uwsgi_file_path" if [ $service = "manage" -o $service = "all" ];then write_port=$(get_config "$service" "write_port") write_ip_addr=$(get_config "$service" "write_ip_addr") @@ -116,15 +129,15 @@ function create_config_file(){ echo "[ERROR] The following config name is needed: daemonize, buffer-size, write_port, write_ip_addr, harakiri and http-timeout" exit 1 fi - if [ -z "$wsgi_file_path" ];then - echo "[ERROR] CAN NOT find the wsgi file path under: /usr/lib/" + if [ -z "$uwsgi_file_path" ];then + echo "[ERROR] CAN NOT find the uwsgi file path under: /usr/lib/" exit 1 fi echo "[INFO] manage.ini is saved to $OUT_PATH/manage.ini" echo "[uwsgi] http=$write_ip_addr:$write_port module=packageship.manage -wsgi-file=$wsgi_file_path/manage.py +uwsgi-file=$uwsgi_file_path/manage.py callable=app buffer-size=$buffer_size pidfile=$OUT_PATH/manage.pid @@ -132,6 +145,7 @@ http-timeout=$http_timeout harakiri=$harakiri enable-threads=true daemonize=$daemonize" > $OUT_PATH/manage.ini +chmod 666 $OUT_PATH/manage.ini fi if [ $service = "selfpkg" -o $service = "all" ];then @@ -143,8 +157,8 @@ daemonize=$daemonize" > $OUT_PATH/manage.ini echo "[ERROR] The following config name is needed: daemonize, buffer_size, query_port, query_ip_addr, harakiri and http-timeout." exit 1 fi - if [ -z "$wsgi_file_path" ];then - echo "[ERROR] CAN NOT find the wsgi file path under: /usr/lib/" + if [ -z "$uwsgi_file_path" ];then + echo "[ERROR] CAN NOT find the uwsgi file path under: /usr/lib/" exit 1 fi @@ -152,7 +166,7 @@ daemonize=$daemonize" > $OUT_PATH/manage.ini echo "[uwsgi] http=$query_ip_addr:$query_port module=packageship.selfpkg -wsgi-file=$wsgi_file_path/selfpkg.py +uwsgi-file=$uwsgi_file_path/selfpkg.py callable=app buffer-size=$buffer_size pidfile=$OUT_PATH/selfpkg.pid @@ -160,7 +174,7 @@ http-timeout=$http_timeout harakiri=$harakiri enable-threads=true daemonize=$daemonize" > $OUT_PATH/selfpkg.ini - +chmod 666 $OUT_PATH/selfpkg.ini fi rm -f config_file @@ -170,7 +184,7 @@ function start_service(){ if [ "`ps aux | grep "uwsgi" | grep "$1.ini"`" != "" ];then echo "[WARNING] $1 service is running, please STOP it first." else - cd $wsgi_file_path + cd $uwsgi_file_path uwsgi -d --ini $OUT_PATH/$1.ini echo "[INFO] START uwsgi service: $1.ini" fi @@ -217,6 +231,7 @@ if [ $? -ne 0 ];then exit 0 fi + if [ $1 = start ] then if [ $service = "all" ];then @@ -239,4 +254,3 @@ elif [ $1 = stop ];then else echo "Usages: sh pkgshipd.sh start|stop [manage|selfpkg]" fi - diff --git a/packageship/pkgship.spec b/packageship/pkgship.spec index 65f3d75ac5aa2c0eff5ba343d330618fe2453d1e..606ce5c1a0cad5934bf6f074a26e9937af484a35 100644 --- a/packageship/pkgship.spec +++ b/packageship/pkgship.spec @@ -1,6 +1,6 @@ Name: pkgship Version: 1.1.0 -Release: 2 +Release: 3 Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so no. License: Mulan 2.0 URL: https://gitee.com/openeuler/openEuler-Advisor @@ -49,11 +49,16 @@ rm -rf $log_path %files %doc README.md %{python3_sitelib}/* -%config %{_sysconfdir}/pkgship/* +%attr(0755,root,root) %config %{_sysconfdir}/pkgship/* %attr(0755,root,root) %{_bindir}/pkgshipd %attr(0755,root,root) %{_bindir}/pkgship %changelog +* Fri Sep 11 2020 Yiru Wang - 1.1.0-3 +- #I1UCM8, #I1UC8G: Modify some config files' permission issue; +- #I1TIYQ: Add concurrent-log-handler module to fix log resource conflict issue +- #I1TML0: Fix the matching relationship between source_rpm and src_name + * Tue Sep 1 2020 Zhengtang Gong - 1.1.0-2 - Delete the packaged form of pyinstaller and change the execution of the command in the form of a single file as the input