config_scripts.sh

来自「Linux嵌入式设计配套光盘,学习嵌入式设计可参考」· Shell 代码 · 共 54 行

SH
54
字号
#!/bin/shheader="#!/usr/local/bin/php"files="setup_network.php setup_snmp.php setup_alarm.php status.php reports_logs.php help_howto.php help_whatif.php help_contact_us.php phpinfo.php wait_for_status.php howto/Add_new_help_topics.php howto/Install_additional_sensors.php whatif/An_alarm_is_not_detected.php whatif/A_zone_stays_in_alarm.php"basename=`basename $0`# shouldn't need to modify below this line if [ $# -lt 1 ]; then    echo "Usage: $basename php"   echo "Usage: $basename cgi <php path>"   exit 1fiscript_type=$1# script_type is either php or cgiif [ "$script_type" != "php" -a "$script_type" != "cgi" ]; then   echo "Usage: $basename php"   echo "Usage: $basename cgi <php path>"   exit 1fifor file in $files; do     if [ ! -f $file ]; then       echo "File $file does not exist, exiting..."       exit 1    fi    # output of following grep will be like "2:<?php 120:<?php"    # pick out the number before the first ':' char    num=`grep -n '<?php' $file | sed 's/\([^:]\):.*/\1/g'`    # create a temporary file    tmp_file=`mktemp /tmp/XXXXXX`     if [ $? -ne 0 ]; then        echo "$basename: Unable to make temp file, exiting..."        exit 1    fi    # write header to this file    msg="Removing header from $file."    if [ "$script_type" = "cgi" ]; then        echo $header > $tmp_file        msg="Adding header $header to $file."    fi    # append to thie file tail +$num     tail +$num $file >> $tmp_file    diff $file $tmp_file > /dev/null    if [ $? -ne 0 ]; then        echo "$0: $msg"        mv $tmp_file $file        chmod a+x $file    fidone

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?