已合并
修复mindie整包非root用户安装失败 #931
hw-zhoutianyang创建于 4月21日
修复mindie整包非root用户安装失败 #931
已合并
共 1 个文件变更+39-35
| @@ -1,4 +1,3 @@ | |||
| 1 | -#!/bin/bash | ||
| 2 | cat << EOF > "$archname" | 1 | cat << EOF > "$archname" |
| 3 | #!/bin/bash | 2 | #!/bin/bash |
| 4 | # This script was generated using Makeself $MS_VERSION | 3 | # This script was generated using Makeself $MS_VERSION |
| @@ -27,6 +26,7 @@ export ARCHIVE_DIR | |||
| 27 | name_of_file="\$0 " | 26 | name_of_file="\$0 " |
| 28 | package_name=\`echo \$name_of_file | cut -d "/" -f2 | sed "s/.run//g" \` | 27 | package_name=\`echo \$name_of_file | cut -d "/" -f2 | sed "s/.run//g" \` |
| 29 | pwd_of_file="\$PWD" | 28 | pwd_of_file="\$PWD" |
| 29 | +SHA_ARG="" | ||
| 30 | label="$LABEL" | 30 | label="$LABEL" |
| 31 | script="$SCRIPT" | 31 | script="$SCRIPT" |
| 32 | scriptargs="$SCRIPTARGS" | 32 | scriptargs="$SCRIPTARGS" |
| @@ -45,7 +45,6 @@ export_conf="$EXPORT_CONF" | |||
| 45 | decrypt_cmd="$DECRYPT_CMD" | 45 | decrypt_cmd="$DECRYPT_CMD" |
| 46 | skip="$SKIP" | 46 | skip="$SKIP" |
| 47 | PACKAGE_LOG_NAME=makeself | 47 | PACKAGE_LOG_NAME=makeself |
| 48 | -readonly user_n=\$(whoami) | ||
| 49 | info_record_path="\$HOME/log/mindie" | 48 | info_record_path="\$HOME/log/mindie" |
| 50 | info_record_file="operation.log" | 49 | info_record_file="operation.log" |
| 51 | info_record_file_bak="operation.log.bak" | 50 | info_record_file_bak="operation.log.bak" |
| @@ -98,7 +97,7 @@ function check_path() { | |||
| 98 | exit 1 | 97 | exit 1 |
| 99 | fi | 98 | fi |
| 100 | } | 99 | } |
| 101 | - | 100 | + |
| 102 | function log_check() { | 101 | function log_check() { |
| 103 | local log_size | 102 | local log_size |
| 104 | log_size=\$(find \$log_file -exec ls -l {} \; | awk '{ print \$5 }') | 103 | log_size=\$(find \$log_file -exec ls -l {} \; | awk '{ print \$5 }') |
| @@ -106,7 +105,7 @@ function log_check() { | |||
| 106 | rotate_log | 105 | rotate_log |
| 107 | fi | 106 | fi |
| 108 | } | 107 | } |
| 109 | - | 108 | + |
| 110 | # usage log "INFO" "this is message" | 109 | # usage log "INFO" "this is message" |
| 111 | function log() { | 110 | function log() { |
| 112 | if [ ! -d "\$info_record_path" ];then | 111 | if [ ! -d "\$info_record_path" ];then |
| @@ -237,11 +236,10 @@ Options: | |||
| 237 | --info Print embedded info : title, default target directory, embedded script ... | 236 | --info Print embedded info : title, default target directory, embedded script ... |
| 238 | --list Print the list of files in the archive | 237 | --list Print the list of files in the archive |
| 239 | --check Checks integrity and version dependency of the archive | 238 | --check Checks integrity and version dependency of the archive |
| 240 | - --quiet Quiet install mode, skip human-computer interactions | 239 | + --quiet | -q Quiet install mode, skip human-computer interactions |
| 241 | If the package requires an EULA, quiet installations are useful for scripting the installation | 240 | If the package requires an EULA, quiet installations are useful for scripting the installation |
| 242 | Using this option means accepting the EULA | 241 | Using this option means accepting the EULA |
| 243 | --extract=<path> Extract directly to a target directory (absolute or relative) | 242 | --extract=<path> Extract directly to a target directory (absolute or relative) |
| 244 | - --tar arg1 [arg2 ...] Access the contents of the archive through the tar command | ||
| 245 | \${helpheader} | 243 | \${helpheader} |
| 246 | EOH | 244 | EOH |
| 247 | } | 245 | } |
| @@ -329,7 +327,7 @@ MS_Decompress() | |||
| 329 | else | 327 | else |
| 330 | eval "$GUNZIP_CMD" | 328 | eval "$GUNZIP_CMD" |
| 331 | fi | 329 | fi |
| 332 | - | 330 | + |
| 333 | if test \$? -ne 0; then | 331 | if test \$? -ne 0; then |
| 334 | echo " ... Decompression failed." >&2 | 332 | echo " ... Decompression failed." >&2 |
| 335 | log "ERROR" "Decompression failed." | 333 | log "ERROR" "Decompression failed." |
| @@ -486,7 +484,7 @@ fi | |||
| 486 | 484 | ||
| 487 | if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then | 485 | if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then |
| 488 | echo "Administrative privileges required for this archive (use su or sudo)" >&2 | 486 | echo "Administrative privileges required for this archive (use su or sudo)" >&2 |
| 489 | - exit 1 | 487 | + exit 1 |
| 490 | fi | 488 | fi |
| 491 | 489 | ||
| 492 | if test x"\$copy" \!= xphase2; then | 490 | if test x"\$copy" \!= xphase2; then |
| @@ -512,30 +510,6 @@ phase2) | |||
| 512 | ;; | 510 | ;; |
| 513 | esac | 511 | esac |
| 514 | 512 | ||
| 515 | -if test x"\$nox11" = xn; then | ||
| 516 | - if tty -s; then # Do we have a terminal? | ||
| 517 | - : | ||
| 518 | - else | ||
| 519 | - if test x"\$DISPLAY" != x -a x"\$xterm_loop" = x; then # No, but do we have X? | ||
| 520 | - if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable | ||
| 521 | - GUESS_XTERMS="xterm gnome-terminal rxvt dtterm eterm Eterm xfce4-terminal lxterminal kvt konsole aterm terminology" | ||
| 522 | - for a in \$GUESS_XTERMS; do | ||
| 523 | - if type \$a >/dev/null 2>&1; then | ||
| 524 | - XTERM=\$a | ||
| 525 | - break | ||
| 526 | - fi | ||
| 527 | - done | ||
| 528 | - chmod a+x \$0 || echo Please add execution rights on \$0 | ||
| 529 | - if test \`echo "\$0" | cut -c1\` = "/"; then # Spawn a terminal! | ||
| 530 | - exec \$XTERM -e "\$0 --xwin \$initargs" | ||
| 531 | - else | ||
| 532 | - exec \$XTERM -e "./\$0 --xwin \$initargs" | ||
| 533 | - fi | ||
| 534 | - fi | ||
| 535 | - fi | ||
| 536 | - fi | ||
| 537 | -fi | ||
| 538 | - | ||
| 539 | if test x"\$targetdir" = x.; then | 513 | if test x"\$targetdir" = x.; then |
| 540 | tmpdir="." | 514 | tmpdir="." |
| 541 | else | 515 | else |
| @@ -610,8 +584,6 @@ do | |||
| 610 | if test x"\$ownership" = xy; then | 584 | if test x"\$ownership" = xy; then |
| 611 | (cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .) | 585 | (cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .) |
| 612 | fi | 586 | fi |
| 613 | - shopt -s nullglob && chmod 550 "\$tmpdir"/*.run "\$tmpdir"/*.gz "\$tmpdir"/*.sh && chmod 440 "\$tmpdir"/*.info "\$tmpdir"/*.txt | ||
| 614 | - shopt -s nullglob && chmod 550 "\$tmpdir" "\$tmpdir"/scripts "\$tmpdir"/scripts/* | ||
| 615 | else | 587 | else |
| 616 | echo >&2 | 588 | echo >&2 |
| 617 | echo "Unable to decompress \$0" >&2 | 589 | echo "Unable to decompress \$0" >&2 |
| @@ -667,11 +639,43 @@ if test x"\$script" != x; then | |||
| 667 | fi | 639 | fi |
| 668 | fi | 640 | fi |
| 669 | 641 | ||
| 642 | +change_permission() | ||
| 643 | +{ | ||
| 644 | + shopt -s nullglob | ||
| 645 | + | ||
| 646 | + for file in "\$tmpdir"/*.run "\$tmpdir"/*.gz "\$tmpdir"/*.sh; do | ||
| 647 | + if [ -e "\$file" ]; then | ||
| 648 | + chmod 550 "\$file" | ||
| 649 | + fi | ||
| 650 | + done | ||
| 651 | + | ||
| 652 | + for info_file in "\$tmpdir"/*.info "\$tmpdir"/*.txt; do | ||
| 653 | + if [ -e "\$info_file" ]; then | ||
| 654 | + chmod 440 "\$info_file" | ||
| 655 | + fi | ||
| 656 | + done | ||
| 657 | + | ||
| 658 | + if [ -d "\$tmpdir" ]; then | ||
| 659 | + chmod 550 "\$tmpdir" | ||
| 660 | + fi | ||
| 661 | + | ||
| 662 | + if [ -d "\$tmpdir"/scripts ]; then | ||
| 663 | + chmod 550 "\$tmpdir"/scripts | ||
| 664 | + for script_file in "\$tmpdir"/scripts/*; do | ||
| 665 | + if [ -e "\$script_file" ]; then | ||
| 666 | + chmod 550 "\$script_file" | ||
| 667 | + fi | ||
| 668 | + done | ||
| 669 | + fi | ||
| 670 | +} | ||
| 671 | + | ||
| 672 | +change_permission | ||
| 670 | MS_exec_cleanup | 673 | MS_exec_cleanup |
| 671 | 674 | ||
| 672 | if test x"\$keep" = xn; then | 675 | if test x"\$keep" = xn; then |
| 673 | cd "\$TMPROOT" | 676 | cd "\$TMPROOT" |
| 677 | + chmod +wx -R "\$tmpdir" | ||
| 674 | rm -rf "\$tmpdir" | 678 | rm -rf "\$tmpdir" |
| 675 | fi | 679 | fi |
| 676 | eval \$finish; exit \$res | 680 | eval \$finish; exit \$res |
| 677 | -EOF | 681 | +EOF |