⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pixil-ifup

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻
字号:
#!/bin/sh# Network configuration script for the Pixil Operating Environment## Usage:  ./pixil-ifup <device> # TODO:# This does some stupid stuff that only allows one device at at time# We should do more checking for gateway / nameserver that will work# across multiple interfaces# RANT:# I hate sed!CONFIG=${1}IFS=NULL[ -z "${CONFIG}" ] && {  echo "usage:  ./pixil-ifup <config | device>"  exit 1}# We assume a default file of /usr/local/pixil/scripts/pixil-<device>.conf[ -f "${CONFIG}" ] || CONFIG=/usr/local/pixil/scripts/pixil-${CONFIG}.conf [ -f "${CONFIG}" ] || {  echo "No config '${CONFIG}' found"  echo "Usage:  ./pixil-ifup <config | device>"  exit 1}# Source the main configuration file# provides HOSTNAME and GATEWAYif [ -f ./pixil-network.conf ]; then    source pixil-network.conffi# Source the config filesource ${CONFIG}# Verify that the device actually exists/sbin/ifconfig ${DEVICE} 2>&1 | grep -s "not found" > /dev/nullif [ "$?" = "0" ]; then   echo "Device ${DEVICE} is not available.  Delaying initialization..."   exit 1fi# Make sure it is downif /sbin/ifconfig ${DEVICE} 2>/dev/null | grep " UP " >/dev/null 2>&1; then   echo "Device ${DEVICE} is already started....."   exit 1fi# Ok, so now the fun stuff if [ "${PROTO}" = dynamic ]; then    PUMPARGS=      if [ -n "HOSTNAME" ]; then       PUMPARGS="${PUMPARGS} -h ${HOSTNAME}"   else      PUMPARGS="${PUMPARGS} --lookup-hostname"   fi   if [ ! -x /sbin/pump ]; then	echo "You don't have pump installed!"	exit 1   fi   # Run the pump     echo -n "Bringing up ${DEVICE}..."   #if ! /sbin/dhcpcd -n ${DEVICE}; then   #	echo "error"   #	exit 1   #else   #	echo "done"   #fi    if [ ! -x "/sbin/pump ${PUMPARGS} -i ${DEVICE}" ]; then     echo "error /sbin/pump ${PUMPARGS} -i ${DEVICE}"      exit 1   else   	echo "done"   fielse # static     # We need at least a IP address     if [ -z "${IPADDR}" ]; then	echo "No ip address was specified.  Bye!"	exit 1     fi     # We can calculate the rest of the required functions     if [ -z "${NETMASK}" ]; then	eval `/bin/ipcalc --netmask ${IPADDR}`     fi     if [ -z "${BROADCAST}" ]; then	eval `/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}`	     fi     if [ -z "${NETWORK}" ]; then	eval `/bin/ipcalc --network ${IPADDR} ${NETMASK}`	     fi     # Other flags make be required here     /sbin/ifconfig ${DEVICE} ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST} 	        # Go ahead and construct all of the routes     /sbin/route add -net ${NETWORK} netmask ${NETMASK} dev ${DEVICE}          # If there is no specified gateway, then add it     # TODO:  Remove the previous one that is there????    if ! /sbin/route -n 2>/dev/null | grep " UG " >/dev/null 2>&1; then	if [ -n "${GATEWAY}" ]; then	 /sbin/route add default gw ${GATEWAY} dev ${DEVICE}	fi	    fi     # Make a new nameserver file     # This is only possible because we have one interface.  Otherwise, we      # have a whole world of hurt here     if [ -n "${NAMESERVER1}" ]; then 	if [ -f /etc/resolv.conf ]; then	   cp /etc/resolv.conf /etc/resolv.conf.backup-${DEVICE}	fi	echo "" > /etc/resolv.conf	if [ -n "${DOMAIN}" ]; then	  echo "search ${DOMAIN}" >> /etc/resolv.conf	fi	if [ -n "${NAMESERVER1}" ]; then	  echo "nameserver ${NAMESERVER1}" >> /etc/resolv.conf	fi	if [ -n "${NAMESERVER2}" ]; then	   echo "nameserver ${NAMESERVER2}" >> /etc/resolve.conf	fi    fi      fi# If we don't want to set any wireless settings, # then leave quietlyif [ ! -n "${ESSID}" ] && [ ! -n "${WEPID}" ]; then    echo "No ESSID or WEPID key."    exit 0fiif [ ! -x /sbin/iwconfig ]; then     echo "/sbin/iwconfig not found."    exit 1fiif /sbin/iwconfig ${DEVICE} 2>&1 | grep "no wireless extensions" >/dev/null 2>&1; then    echo "No wireless available for ${DEVICE}"    exit 1fiIWCONFIG_ARGS=if [ -n "${ESSID}" ]; then    echo -n "setting essid to ${ESSID}..."    IWCONFIG_ARGS="/sbin/iwconfig ${DEVICE} essid \"${ESSID}\""    echo "done."fiif [ -n "${IWCONFIG_ARGS}" ]; then	echo "${IWCONFIG_ARGS}"	${IWCONFIG_ARGS}fiexit 0          

⌨️ 快捷键说明

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