Добро пожаловать! Это — архивная версия форумов на «Хакер.Ru». Она работает в режиме read-only.
 

скриптег...

Пользователи, просматривающие топик: none

Зашли как: Guest
Все форумы >> [*nix/Linux] >> скриптег...
Имя
Сообщение << Старые топики   Новые топики >>
скриптег... - 2006-11-09 21:12:15.020000   
hladon

Сообщений: 334
Оценки: 0
Присоединился: 2005-12-29 07:46:40
Короче я скачал драйвер для своего winodem'a for linux (linuxant.com)
Эти уроды требуют за драйвер модема стоимостью 10$ почти 20$. Есть триал (с него и пишу) - 14.4 kbps на 1 месяц - не прет меня так((
Поэтому решил поправить исходники hsfconfig - утилита конфигурации, требующая серийник.
Там есть функция, возвращающая результаты регистрации, но простое её редактирование с целью чтобы она всегда возвращала одно и то жн не помогает - может кто помогет разобраться?



#!/bin/bash
#
# Copyright © 2003-2004 Linuxant inc.
#
# NOTE: The use and distribution of this software is governed by the terms in
# the file LICENSE, which is included in the package. You must read this and
# agree to these terms before using or distributing this software.
#
# This script handles all aspects of installing and configuring the
# Conexant HSF softmodem driver under Linux.
#
# It tries to be as distribution-neutral as possible.

ask_yesno()
{
$automode && return $2

while true; do
echo -n "$1"
read answer
case "${answer}" in
[yY] | [yY][eE][sS])
return 0
;;
[nN] | [nN][oO])
return 1
;;
"")
return $2
;;
*)
echo "Enter 'yes' or 'no'"
;;
esac
done
}

get_region_list()
{
(cd ${cnxtnvmdir}/${parm_hwprofile[${unit}]}/Region/ && grep '^' ????_NAME) | \
sed -e 's/ /_/g' -e 's/^\(….\)_NAME:"\(.*\)"/\2 \1/' | sort
}

T35c_to_name()
{
sed -e 's/"//g' -e 's/ /_/g' \
&lt; ${cnxtnvmdir}/${parm_hwprofile[${unit}]}/Region/${1}_NAME
}

join_comma_wrap_lines()
{
${AWK} '{
if (NR != 1) printf ", "
printf "%s",$1
}
END { print ""}' | fold -s -w78
}

ask_region()
{
get_region_list &gt; /var/run/cnxtconf.sup.$$

while true; do
if [ -n "${setregion}" ]; then
answer="${setregion}"
elif ${automode}; then
answer="${region}"
else
echo ""
echo -n "Please enter region name for modem unit ${unit} [$region]: "
read answer
case "${answer}" in
"" | *"[ ]"*)
answer="${region}"
;;
*)
answer="`echo \"${answer}\" | tr '[a-z ]' '[A-Z_]'`"
;;
esac
fi

if grep -i "^${answer}\** " /var/run/cnxtconf.sup.$$ &gt; /var/run/cnxtconf.ncty.$$
then
read region regioncode &lt; /var/run/cnxtconf.ncty.$$
rm -f /var/run/cnxtconf.sup.$$ /var/run/cnxtconf.ncty.$$
return 0
else
echo ""
echo "ERROR: Region \"${answer}\" is not supported."

if ${automode}; then
rm -f /var/run/cnxtconf.sup.$$ /var/run/cnxtconf.ncty.$$
return 1
fi
setregion=""
echo ""
echo "Available countries: "
echo ""

grep -v '\*' /var/run/cnxtconf.sup.$$ | join_comma_wrap_lines
echo ""
grep '\*' /var/run/cnxtconf.sup.$$ | tr -d '\*' | join_comma_wrap_lines

fi
done
}

autodetect_region()
{
# Try to guess what region we're in, using the timezone settings

localtime_size="`/bin/ls -lL /etc/localtime 2&gt;/dev/null | ${AWK} '{print $5}'`"

if ! [ ${localtime_size} -gt 0 ]; then
return 1
fi

zoneinfo_dir=/usr/share/zoneinfo

if [ ! -d ${zoneinfo_dir} -o ! -f ${zoneinfo_dir}/zone.tab ]; then
return 1
fi

# The following maps ISO-3166 country codes to T.35 codes
iso_AR=0007 # ARGENTINA
iso_AU=0009 # AUSTRALIA
iso_AT=000A # AUSTRIA
iso_BH=000C # BAHRAIN
iso_BD=000D # BANGLADESH
iso_BE=000F # BELGIUM
iso_BO=0014 # BOLIVIA
iso_BR=0016 # BRAZIL
iso_BN=001A # BRUNEI
iso_BG=001B # BULGARIA
iso_CA=0020 # CANADA
iso_CL=0025 # CHILE
iso_CN=0026 # CHINA
iso_CO=0027 # COLOMBIA
iso_CR=002B # COSTA_RICA
iso_HR=00FA # CROATIA
iso_CY=002D # CYPRUS
iso_CZ=002E # CZECH
iso_DK=0031 # DENMARK
iso_DO=0033 # DOMINICAN_REPUBLIC
iso_EC=0035 # ECUADOR
iso_EG=0036 # EGYPT
iso_SV=0037 # EL_SALVADOR
iso_FI=003C # FINLAND
iso_FR=003D # FRANCE
iso_DE=0004 # GERMANY
iso_GR=0046 # GREECE
iso_GT=0049 # GUATEMALA
iso_HT=004E # HAITI
iso_HN=004F # HONDURAS
iso_HK=0050 # HONG_KONG
iso_HU=0051 # HUNGARY
iso_IS=0052 # ICELAND
iso_IN=0053 # INDIA
iso_ID=0054 # INDONESIA
iso_IE=0057 # IRELAND
iso_IL=0058 # ISRAEL
iso_IT=0059 # ITALY
iso_JP=0000 # JAPAN
iso_KR=0061 # KOREA
iso_KW=0062 # KUWAIT
iso_LA=0063 # LAOS
iso_LV=00F8 # LATVIA
iso_LI=0068 # LIECHTENSTEIN
iso_LU=0069 # LUXEMBOURG
iso_MO=006A # MACAO
iso_MY=006C # MALAYSIA
iso_MT=0070 # MALTA
iso_MX=0073 # MEXICO
iso_MN=001C # MYANMAR
iso_NL=007B # NETHERLANDS
iso_NZ=007E # NEW_ZEALAND
iso_NO=0082 # NORWAY
iso_PK=0084 # PAKISTAN
iso_PA=0085 # PANAMA
iso_PY=0087 # PARAGUAY
iso_PE=0088 # PERU
iso_PH=0089 # PHILIPPINES
iso_PL=008A # POLAND
iso_PT=008B # PORTUGAL
iso_PR=008C # PUERTO_RICO
iso_RO=008E # ROMANIA
iso_RU=00B8 # RUSSIA
iso_SA=0098 # SAUDI_ARABIA
iso_SG=009C # SINGAPORE
iso_SK=00FB # SLOVAKIA
iso_SI=00FC # SLOVENIA
iso_ZA=009F # SOUTH_AFRICA
iso_ES=00A0 # SPAIN
iso_LK=00A1 # SRI_LANKA
iso_SE=00A5 # SWEDEN
iso_CH=00A6 # SWITZERLAND
iso_TW=00FE # TAIWAN
iso_TH=00A9 # THAILAND
iso_TR=00AE # TURKEY
iso_GB=00B4 # UK
iso_UA=00B2 # UKRAINE
iso_AE=00B3 # UNITED_ARAB_EMIRATES
iso_UY=00B7 # URUGUAY
iso_US=00B5 # USA
iso_VE=00BB # VENEZUELA
iso_VN=00BC # VIETNAM

(
cd ${zoneinfo_dir} 2&gt;/dev/null || return 1
find . -type f -size "${localtime_size}"c -print | sed 's@^\./@@' | \
while read file; do
cmp -s /etc/localtime $file || continue
# in the egrep and sed regular expressions below, it is very important to
# have tabs, not spaces
egrep " $file( .*|\$)" ${zoneinfo_dir}/zone.tab
done | sed -n '/^[^#]/s/ .*//p' | sort | uniq | \
while read code; do
eval "echo \${iso_${code}}"
done | sort | uniq
return 0
)
}

configure_region()
{
region="${setregion}"
if [ -z "${region}" -a -n "${parm_regionName[${unit}]}" ]; then
region="${parm_regionName[${unit}]}"
fi

if [ -z "${region}" -o "${region}" = "AUTO" ]; then
if [ -z "${autoregion}" ]; then
regiont35="`autodetect_region | head -n 1`"
echo ""
if [ -z "${regiont35}" ]; then
echo "Unable to determine region, defaulting to \"USA\""
autoregion=USA
else
autoregion="`T35c_to_name \"${regiont35}\"`"
echo "Automatically guessed region (using timezone): \"${autoregion}\""
fi
fi
region="${autoregion}"
if [ "${setregion}" = "AUTO" ]; then
setregion="${autoregion}"
fi
fi

ask_region || return 1

parm_regionName[${unit}]="${region}"
parm_regionT35c[${unit}]="${regioncode}"

if ! hsfstop &gt;/dev/null 2&gt;&1; then
echo ""
echo "Unable to unload driver to configure region; modem in use?"
echo "try configuring it manually with \"AT+GCI=${parm_regionT35c[${unit}]}\""
fi
sleep 1

echo ""
echo "Setting region for modem unit ${unit}: \"${parm_regionName[${unit}]}\""
touch ${cnxtnvmdir}/dynamic/${parm_hwinst[${unit}]}/.region_set
echo "${parm_regionT35c[${unit}]}" &gt; ${cnxtnvmdir}/dynamic/${parm_hwinst[${unit}]}/COUNTRY_CODE
res=$?

return ${res}
}

# Convert a key from display to internal format
# The md5sum is used for input verification.
disptokey()
{
k="`echo \"$1\" | tr '[a-z]' '[A-Z]' | sed 's/FREE/00000000/' | tr -d -c '[0-9A-F\012]'`"
case $k in
00000000)
echo "$k"
;;
????????????)
key="`echo \"$k\" | cut -c1-8`"
if [ "`echo \"${key}\" | md5sum | cut -c1-4 | tr '[a-f]' '[A-F]'`" = "`echo \"$k\" | cut -c9-12`" ]; then
echo "${key}"
else
echo "checksum error"
fi
;;
*)
echo "format error"
;;
esac
}

# Convert a key from internal to display format
# The md5sum is generated for input verification.
keytodisp()
{
key="$1"

if [ "${key}" = "00000000" ]; then
echo FREE
return 0
fi

sum="`echo \"${key}\" | md5sum | cut -c1-4 | tr '[a-f]' '[A-F]'`"

echo "${key}${sum}" | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)$/\1-\2-\3-\4-\5-\6/'
}

ask_license()
{
while true; do
if [ -n "${setlicense}" ]; then
answer="`disptokey \"${setlicense}\"`"
elif ${automode}; then
answer="${license}"
else
echo ""

echo "License keys can be obtained from http://www.linuxant.com/"
echo "Without one, the modem operates in FREE mode (max 14.4Kbps data only, no fax)"
echo ""
echo "The registration ID for modem unit ${unit} is: ${parm_hwid[${unit}]}"
echo ""
echo -n "Please enter license key [`keytodisp \"$license\"`]: "
read answer
case "${answer}" in
"" | *"[ ]"*)
answer="${license}"
;;
*)
answer="`disptokey \"${answer}\"`"
;;
esac
fi

case "${answer}" in
[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F])
license="${answer}"
return 0
;;
*)
echo ""
echo "ERROR: Invalid license key: \"${answer}\"."
if ${automode}; then
return 1
fi
setlicense=""
;;
esac
done
}

ask_licowner()
{
while true; do
if [ -n "${setlicowner}" ]; then
answer="${setlicowner}"
elif ${automode}; then
if [ -z "${licowner}" ]; then
return 1
fi
answer="${licowner}"
else
echo ""
echo "Note: we respect user privacy. Email addresses are not communicated"
echo "nor used for any purpose other than to manage licenses!"
echo ""

echo -n "Please enter your email address [$licowner]: "
read answer
case "${answer}" in
"" | *"[ ]"*)
answer="${licowner}"
;;
*)
answer="`echo \"${answer}\" | tr '[A-Z]' '[a-z]' | tr -d '[ &lt;&gt;\012]'`"
;;
esac
fi

case "${answer}" in
?*@?*.?*)
licowner="${answer}"
return 0
;;
*)
if ! ${automode} || [ "${answer}" != "unknown" ]; then
echo ""
echo "ERROR: Invalid email address format: \"${answer}\"."
fi
if ${automode}; then
return 1
fi
setlicowner=""
;;
esac
done
}

needfullversion() {
echo ""
echo "This is the free version of the driver, limited to 14.4Kbps data only."
echo "For 56K modem and FAX functionality, please upgrade to the full version"
echo "available from http://www.linuxant.com/"
}

configure_license()
{
if ${isfreeversion}; then
needfullversion
return 1
fi

licowner="${setlicowner}"
if [ -z "${licowner}" -a -n "${parm_licowner[${unit}]}" ]; then
licowner="${parm_licowner[${unit}]}"
if [ "${licowner}" = "unknown" ]; then
licowner="${lastowner}"
fi
fi

case "${setlicense}" in
?*/?*)
setlicowner="`echo \"${setlicense}\" | ${AWK} -F/ '{print $1}'`"
setlicense="`echo \"${setlicense}\" | ${AWK} -F/ '{print $2}'`"
;;
*)
;;
esac

if [ -z "${setlicense}" ]; then
if [ -n "${parm_lickey[${unit}]}" ]; then
license="${parm_lickey[${unit}]}"
else
license=""
fi
else
license="`disptokey \"${setlicense}\"`"
fi

ask_licowner || return 1
parm_licowner[${unit}]="${licowner}"

ask_license || return 1
parm_lickey[${unit}]="${license}"

if ! hsfstop &gt;/dev/null 2&gt;&1; then
echo ""
echo "Unable to unload driver to configure license; modem in use?"
echo "\"License status\" information might not be up to date."
echo "Please reboot your computer."
fi
sleep 1

echo ""
echo "Setting license for modem unit ${unit}: \"${parm_licowner[${unit}]}/`keytodisp \"${parm_lickey[${unit}]}\"`\""
echo "\"${parm_licowner[${unit}]}\"" &gt; ${cnxtnvmdir}/dynamic/${parm_hwinst[${unit}]}/LICENSE_OWNER
[ -n "${parm_licowner[${unit}]}" -a "${parm_licowner[${unit}]}" != "unknown" ] && lastowner="${parm_licowner[${unit}]}"
echo "${parm_lickey[${unit}]}" &gt; ${cnxtnvmdir}/dynamic/${parm_hwinst[${unit}]}/LICENSE_KEY
rereadparms=true
res=$?

return ${res}
}

get_hwprofile_list()
{
echo "auto"
(cd ${cnxtnvmdir} && find . -follow -type d -maxdepth 1 -print) | \
egrep -v '^\.(\/dynamic)?$' | sed 's@^\./@@' | sort
}

ask_hwprofile()
{
get_hwprofile_list &gt; /var/run/cnxtconf.sup.$$

while true; do
if [ -n "${sethwprofile}" ]; then
answer="${sethwprofile}"
elif ${automode}; then
answer="${hwprofile}"
else
echo ""
echo "Available hardware profiles: "
echo ""

${AWK} '{
if (NR != 1) printf ", "
if (NR % 5 == 0) print ""
printf "%s",$1
}
END { print ""}' &lt;/var/run/cnxtconf.sup.$$

echo ""
echo "WARNING: choosing an incorrect profile may make the modem unusable"
echo "or cause system crashes. Use with extreme care!"
echo ""
echo -n "Please enter hardware profile name for modem unit ${unit} [$hwprofile]: "
read answer
case "${answer}" in
"" | *"[ ]"*)
answer="${hwprofile}"
;;
*)
;;
esac
fi

if grep -q -i "^${answer}$" /var/run/cnxtconf.sup.$$
then
hwprofile="${answer}"
rm -f /var/run/cnxtconf.sup.$$
return 0
else
echo ""
echo "ERROR: \"${answer}\" is not available."

if ${automode}; then
rm -f /var/run/cnxtconf.sup.$$
return 1
fi
sethwprofile=""
fi
done
}

configure_hwprofile()
{
hwprofile="${sethwprofile}"
if [ -z "${hwprofile}" -a -n "${parm_hwprofile[${unit}]}" ]; then
if [ -s ${cnxtnvmdir}/dynamic/${parm_hwinst[${unit}]}/HARDWARE_PROFILE ]; then
hwprofile="${parm_hwprofile[${unit}]}"
else
hwprofile="auto"
fi
fi

ask_hwprofile || return 1
parm_hwprofile[${unit}]="${hwprofile}"

if ! hsfstop &gt;/dev/null 2&gt;&1; then
echo ""
echo "Unable to unload driver to configure hwprofile; modem in use?"
fi
sleep 1

echo ""
echo "Setting hwprofile for modem unit ${unit}: \"${hwprofile}\""
if [ "${parm_hwprofile[${unit}]}" = "auto" ]; then
rm -f ${cnxtnvmdir}/dynamic/${parm_hwinst[${unit}]}/HARDWARE_PROFILE
parm_hwprofile[${unit}]="unknown"
rereadparms=true
else
echo "\"${parm_hwprofile[${unit}]}\"" &gt; ${cnxtnvmdir}/dynamic/${parm_hwinst[${unit}]}/HARDWARE_PROFILE
fi
res=$?

return ${res}
}

use_prebuilt_modules()
{
cp -p –remove-destination "${cnxtlibdir}/modules/binaries/$1/"*.${KO} "/lib/modules/${OSKERNVERS}/extra/"
}

files_present()
{
missing_file=""
for f; do
if [ ! -f "${f}" ]; then
missing_file="${f}"
return 1
fi
done
return 0
}

remove_temp_kernel_tree()
{
if [ -n "${KERNELORG}" ]; then
rm -rf "${KERNELSRC}"
KERNELSRC="${KERNELORG}"
KERNELORG=""
return 0
fi

return 1
}

create_temp_kernel_tree()
{
KERNELORG="${KERNELSRC}"
# get absolute pathname with cd/pwd to ensure that our temp dir
# is on same filesystem due to use of hardlinks by cp -al
KERNELSRC="`(cd \"${KERNELORG}\" && /bin/pwd)`-cnxttmp$$"
rm -rf "${KERNELSRC}"
if ! cp -al "${KERNELORG}/." "${KERNELSRC}"; then
remove_temp_kernel_tree
return 1
fi

return 0
}

kernelrebuild_instructions()
{
echo ""
echo "First, ensure that the proper kernel source and compiler packages"
echo "from your distribution vendor and/or the community are installed."
echo ""
echo "The Linux kernel can then be reconfigured by running \"make menuconfig\""
echo "under the kernel source directory (usually /usr/src/linux)."
echo ""
echo "Verify that the proper options for your system are selected."
echo ""
echo "Then compile and install your new kernel (for more information about"
echo "this procedure, see the README file under the kernel source directory),"
echo "reboot the system using the new kernel, and re-run \"hsfconfig\"."
}

check_kernel()
{
# if [ -n "$OSKERNSMP" ]; then
# echo 1&gt;&2 ""
# echo 1&gt;&2 "This driver has not been fully tested on SMP kernels."
# echo 1&gt;&2 "Please report results to &lt;modem.support@linuxant.com&gt;"
# fi

case "${OSKERNVERS}" in
2.[01235].*)
echo ""
echo 1&gt;&2 "ERROR: ${OSKERNVERS} kernels are no longer supported by this driver!"
echo 1&gt;&2 "Please upgrade your Linux distribution or kernel to version 2.4 or 2.6"
return 1
;;
*)
;;
esac

return 0
}

install_patch()
{
patch_file="$1"

echo ""

if [ "${PACKTYPE}" != "TAR" ]; then
echo 1&gt;&2 "ERROR: The –patch option can only be used with the generic package in the TAR"
echo 1&gt;&2 "format."
return 1
fi

(
cd "${PACKSRCDIR}/scripts" || return 1
# Just in case the user decides to clean the source tree…
if [ ! -e patcher ]; then
make patcher &gt; /dev/null 2&gt;&1 || return 1
fi
./patcher "${patch_file}"
ret=$?

if [ ${ret} -eq 100 ]; then
cd .. && make clean &gt;/dev/null 2&gt;&1
fi

return ${ret}
)

if [ $? -eq 100 ]; then
echo ""
echo "Patch applied. You may now re-install the updated software by running"
echo "\"make install\" from the ${PACKSRCDIR} directory."
return 0
else
return $?
fi
}

check_kernel_config()
{
if [ ! -e "${KERNELSRC}/.config" ]; then
return 0
fi

missing=
nb=0
for opt in ${KERN_CONFIG_REQUIRED}; do
if kernel_option_exists "${opt}" && ! kernel_option_set "${opt}"; then
if [ ${nb} -eq 0 ]; then
missing="CONFIG_${opt}"
nb=1
else
missing="${missing} CONFIG_${opt}"
nb=`expr ${nb} + 1`
fi
fi
done

if [ ${nb} -gt 1 ]; then
plurial=s
This=These
this=these
is=are
else
plurial=
This=This
this=this
is=is
fi

if [ -n "${missing}" ]; then
echo 1&gt;&2
echo 1&gt;&2 "ERROR: The kernel at '${KERNELSRC}' was compiled without the following"
echo 1&gt;&2 "option${plurial} enabled: ${missing}"
echo 1&gt;&2 "${This} option${plurial} ${is} needed for the hsf driver. Please enable"
echo 1&gt;&2 "${this} kernel option${plurial}, re-compile the kernel and try again."
return 1
fi

present=
nb=0
for opt in ${KERN_CONFIG_WARNING}; do
if kernel_option_set "${opt}"; then
if [ ${nb} -eq 0 ]; then
present="CONFIG_${opt}"
nb=1
else
present="${present} CONFIG_${opt}"
nb=`expr ${nb} + 1`
fi
fi
done

if [ ${nb} -gt 1 ]; then
plurial=s
This=These
this=these
is=are
else
plurial=
This=This
this=this
is=is
fi

if [ -n "${present}" ]; then
echo 1&gt;&2
echo 1&gt;&2 "WARNING: The kernel at '${KERNELSRC}' was compiled with the following"
echo 1&gt;&2 "option${plurial} enabled: ${present}"
echo 1&gt;&2 "${This} option${plurial} ${is} known to be problematic on some systems."
echo 1&gt;&2 "If you experience any problems, please disable ${this} option${plurial},"
echo 1&gt;&2 "re-compile the kernel and run the 'hsfconfig -k' command in"
echo 1&gt;&2 "a root shell before you ask for help."
fi

return 0
}

kernel_option_exists()
{
grep -q "CONFIG_${1}[= ]" "${KERNELSRC}/.config"
return $?
}

kernel_option_set()
{
grep -q "^CONFIG_${1}=[yYmM]" "${KERNELSRC}/.config"
return $?
}


is_gcc_installed()
{
if [ -z "${GCC_INSTALLED}" ]; then
if which gcc &gt;/dev/null 2&gt;&1; then
GCC_INSTALLED=0
else
GCC_INSTALLED=1
fi
fi

return ${GCC_INSTALLED}
}

right_version_file()
{
_versionf="$1"

if ! is_gcc_installed; then
echo ""
echo "ERROR: gcc is required to build kernel modules."
echo "Please install it and try again."
return 2
fi

FILEKERNELVER="`echo UTS_RELEASE | gcc -E -I"${KERNELSRC}/include" -include "${_versionf}" - | grep '^"' | tr -d '" '`"

[ "${OSKERNVERS}" = "${FILEKERNELVER}" ] || return 1

return 0
}

right_version_kernel_tree()
{
if [ -e "${KERNELSRC}/include/linux/utsrelease.h" ]; then
right_version_file "${KERNELSRC}/include/linux/utsrelease.h"
else
right_version_file "${KERNELSRC}/include/linux/version.h"
fi

return $?
}

update_module_dependencies()
{
depmod -a -e -u &gt;/var/run/cnxtconf.depmod.$$ 2&gt;&1
res=$?

cat 1&gt;&2 /var/run/cnxtconf.depmod.$$

if [ ${res} -ne 0 ]; then
# only return error if one of our modules is at cause
grep -q "hsf" /var/run/cnxtconf.depmod.$$ || res=0
fi

rm -f /var/run/cnxtconf.depmod.$$

disable_conflicting_modules

return ${res}
}

kernel_headers_instructions_fc4_style()
{
case "${OSKERNVERS}" in
smp) KERNHDRSTYPE="-smp"; KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/smp$//'`" ;;
xen0) KERNHDRSTYPE="-xen0"; KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/xen0$//'`" ;;
xenU) KERNHDRSTYPE="-xenU"; KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/xenU$//'`" ;;
*) KERNHDRSTYPE=; KERNHDRSVER="${OSKERNVERS}" ;;
esac

echo "Please install the 'kernel${KERNHDRSTYPE}-devel-${KERNHDRSVER}' package."
echo "You can install this package with the command:"
echo " yum install kernel${KERNHDRSTYPE}-devel-${KERNHDRSVER}"
}

kernel_headers_instructions()
{
if [ "${OSDISTIDNT}" = "deb" ]; then
echo "Please install the 'kernel-headers-${OSKERNVERS}' package. You can install"
echo "it with the 'apt-get install kernel-headers-${OSKERNVERS}' command."
return 0
elif [ "${OSDISTIDNT}" = "ubuntu" ]; then
echo "Please install the 'linux-headers-${OSKERNVERS}' package. You can install"
echo "it with the 'apt-get install linux-headers-${OSKERNVERS}' command."
return 0
elif [ "${OSDISTIDNT}" = "xandros" ]; then
KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/-x[0-9]*$//'`"
EXTRAVER="`echo ${OSKERNVERS} | sed -e 's/^[^-]*-//'`"
echo "Please install the 'xandros-kernel-source-${KERNHDRSVER}' package. You can"
echo "install it with the 'apt-get install xandros-kernel-source-${KERNHDRSVER}'"
echo "command. Then run the following commands:"
echo
echo "—"
echo "cd /usr/src"
echo "tar -xjf xandros-kernel-source-${KERNHDRSVER}.tar.bz2"
echo "—"
echo
echo "Then, edit the file '/usr/src/xandros-kernel-source-${KERNHDRSVER}/Makefile'"
echo "and change the line near the top of the file:"
echo
echo "—"
echo "EXTRAVERSION ="
echo "—"
echo
echo "to:"
echo
echo "—"
echo "EXTRAVERSION = ${EXTRAVER}"
echo "—"
echo
echo "Finally, please run the following commands:"
echo
echo "—"
echo "cd /usr/src/xandros-kernel-source-${KERNHDRSVER}"
echo "cp /boot/config-${OSKERNVERS} .config"
echo "make oldconfig prepare-all"
echo "—"
return 0
elif [ "${OSDISTIDNT}" = "linspire" ]; then
echo "Please use Click and Run to install the following packages:"
echo
echo "—"
echo "los-kernel-config-${OSKERNVERS}"
echo "los-kernel-headers-${OSKERNVERS}"
echo "los-kernel-source-${OSKERNVERS}"
echo "—"
echo
echo "Then run the following commands:"
echo
echo "—"
echo "cd /usr/src"
echo "tar -xzf los-kernel-config-${OSKERNVERS}"
echo "tar -xzf los-kernel-headers-${OSKERNVERS}"
echo "tar -xzf los-kernel-source-${OSKERNVERS}"
echo "—"
return 0
elif [ "${OSDISTIDNT}" = "suse" ]; then
KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/-[^-]*$//'`"
echo "Please install the 'kernel-source-${KERNHDRSVER}' package. You can install"
echo "this package with the 'yast -i kernel-source-${KERNHDRSVER}' command."
return 0
elif [ "${OSDISTIDNT}" = "mdk" ]; then
KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/smp$//'`"
echo "Please install the 'kernel-source-${KERNHDRSVER}' package. You can install"
echo "it with the 'urpmi kernel-source-${KERNHDRSVER}' command."
return 0
elif [ "${OSDISTIDNT}" = "mdv" ]; then
KERNHDRSVER="`echo ${OSKERNVERS} | awk -F- '{print $1 "-" $2}'`"
KERNMINVER="`echo ${OSKERNVERS} | awk -F. '{print $1 "." $2}'`"
echo "Please install the 'kernel-source-${KERNMINVER}-${KERNHDRSVER}' package. You can install"
echo "it with the 'urpmi kernel-source-${KERNMINVER}-${KERNHDRSVER}' command."
return 0
elif [ "${OSDISTIDNT}" = "turbo" ]; then
KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/smp$//' -e 's/smp64G$//' -e 's/numa$//'`"
echo "Please install the 'kernel-headers-${KERNHDRSVER}' as well as the"
echo "'kernel-source-${KERNHDRSVER}' packages."
elif [ "${OSDISTIDNT}" = "fdr" ]; then
case "${OSDISTVERS}" in
1)
KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/smp$//'`"
echo "Please install the 'kernel-source-${KERNHDRSVER}' package. You can install"
echo "it with the 'yum install kernel-source-${KERNHDRSVER}' command."
return 0
;;
2)
# The kernel headers files are in the kernel image package
return 0
;;
3)
# The kernel headers files are in the kernel image package for old FC3 kernels
if [ -h "/lib/modules/`uname -r`/build" ]; then
kernel_headers_instructions_fc4_style
fi
return 0
;;
4 | 5)
kernel_headers_instructions_fc4_style
return 0
;;
esac
elif [ "${OSDISTIDNT}" = "rh" ]; then
case "${OSDISTVERS}" in
EL*)
case "${OSDISTVERS}" in
EL2 | EL2.? | EL3 | EL3.?)
KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/EL.*$/EL/'`"
echo "Please install the 'kernel-source-${OSHDRSVERS}' package."
return 0
;;
EL4 | EL4.?)
case "${OSKERNVERS}" in
smp) KERNHDRSTYPE="-smp"; KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/smp$//'`" ;;
hugemem) KERNHDRSTYPE="-hugemem"; KERNHDRSVER="`echo ${OSKERNVERS} | sed -e 's/hugemem$//'`" ;;
*) KERNHDRSTYPE=; KERNHDRSVER="${OSKERNVERS}" ;;
esac

echo "Please install the 'kernel${KERNHDRSTYPE}-devel-${KERNHDRSVER}' package. You"
echo "can install this package with the 'yum install"
echo "kernel${KERNHDRSTYPE}-devel-${KERNHDRSVER}' command."
return 0
;;
esac
;;
*)
echo "Please install the 'kernel-source-${OSKERNVERS}' package."
return 0
;;
esac
elif [ "${OSDISTIDNT}" = "knoppix" ]; then
# Kernel headers are automatically installed when Knoppix is installed to the HD
return 0
elif [ "${OSDISTIDNT}" = "mepis" ]; then
if [ -e "/usr/src/KERNEL-README" ]; then
echo "Please read the file '/usr/src/KERNEL-README' for instructions on how to"
echo "build the kernel source tree."
return 0
else
# Version 3.4 and later
echo "Please install the 'linux-headers-${OSKERNVERS}' package. You can install"
echo "it with the 'apt-get install linux-headers-${OSKERNVERS}' command."
fi
fi

return 1
}

recompile_modules()
{
KERNELSRC=/usr/src/linux
KERNELORG=""

if [ -h /lib/modules/${OSKERNVERS}/build -a ! -d /lib/modules/${OSKERNVERS}/build/. ]; then
echo ""
echo "ERROR: /lib/modules/${OSKERNVERS}/build points to a missing directory"
echo ""
ls -l /lib/modules/${OSKERNVERS}/build
echo ""
kernel_headers_instructions
return 1
fi

if [ -d /lib/modules/${OSKERNVERS}/build/include ]; then
KERNELSRC=/lib/modules/${OSKERNVERS}/build
elif [ ! -d "${KERNELSRC}" -a -d "/usr/src/kernel-headers-${OSKERNVERS}" ]; then
# Debian
KERNELSRC=/usr/src/kernel-headers-${OSKERNVERS}
elif [ ! -d "${KERNELSRC}" -a -d "/usr/local/src/linux" ]; then
KERNELSRC=/usr/local/src/linux
elif [ ! -d "${KERNELSRC}" ]; then
kernel_headers_instructions
fi
if ! $automode; then
echo ""
echo "Where is the linux source build directory that matches your running kernel?"
echo -n "[${KERNELSRC}] "
read answer
case "${answer}" in
"")
;;
*)
KERNELSRC="${answer}"
;;
esac
fi

# TurboLinux
if [ ! -f "${KERNELSRC}/.config" -a -f "${KERNELSRC}/SetupKernelSource.sh" ]; then
case "${OSKERNVERS}" in
*smp)
SETUPKERNTYPE=i586smp
;;
*smp64G)
SETUPKERNTYPE=i586smp64G
;;
*)
SETUPKERNTYPE=i586
;;
esac

echo ""
echo "Kernel tree in ${KERNELSRC} not configured; running SetupKernelSource.sh ${SETUPKERNTYPE}"
sleep 1
(cd "${KERNELSRC}" && ./SetupKernelSource.sh ${SETUPKERNTYPE})
fi

if [ -e "${KERNELSRC}/scripts/kconfig" ]; then
use_kbuild=true
else
use_kbuild=false
fi

if ! files_present \
"${KERNELSRC}/include/linux/autoconf.h" \
"${KERNELSRC}/include/linux/version.h"; then
echo ""
echo "WARNING: missing file ${missing_file}"
suspect_tree=true
else
right_version_kernel_tree

case $? in
0)
suspect_tree=false
;;
1)
echo ""
echo "WARNING: the kernel version (${FILEKERNELVER}) defined in"
echo "${KERNELSRC}/include/linux/version.h"
echo "does not match the currently running kernel (${OSKERNVERS})"
echo "The cause of this problem is an incorrect kernel source path."
echo "Please check that ${KERNELSRC} points to the right tree."
suspect_tree=true
;;
2)
return 1
;;
esac
fi

if ${suspect_tree}; then
echo "The cause of this is usually a missing or unconfigured"
echo "kernel source tree (and sometimes an incorrect directory or symbolic link)."
# SuSE has a copy of .config available under /boot for newer kernels
if [ -d "${KERNELSRC}/include/linux" -a -f /boot/config-${OSKERNVERS} ]; then
echo ""
echo "However, proper /boot/config-${OSKERNVERS} was found."
if ask_yesno "Would you like to try using it (in a temporary kernel tree)? [yes] " 0; then
if ! create_temp_kernel_tree; then
echo ""
echo "Unable to create temporary kernel tree"
kernelrebuild_instructions
return 1
fi
rm -f "${KERNELSRC}/include/linux/.config" \
"${KERNELSRC}/include/linux/autoconf.h" \
"${KERNELSRC}/include/linux/version.h"
if ! cp -p /boot/config-${OSKERNVERS} "${KERNELSRC}/.config"; then
echo ""
echo "Unable to copy files to temporary kernel tree"
remove_temp_kernel_tree
kernelrebuild_instructions
return 1
fi
if ! (cd ${KERNELSRC} && make oldconfig prepare-all) &gt;/dev/null 2&gt;&1; then
echo ""
echo "Unable to prepare temporary kernel tree"
remove_temp_kernel_tree
kernelrebuild_instructions
return 1
fi
fi
# SuSE has copies of autoconf.h and version.h available under /boot
elif [ -d "${KERNELSRC}/include/linux" -a -f /boot/vmlinuz.autoconf.h -a -f /boot/vmlinuz.version.h ] && right_version_file /boot/vmlinuz.version.h; then
echo ""
echo "However, proper /boot/vmlinuz.{autoconf.h,version.h} were found."
if ask_yesno "Would you like to try using them (in a temporary kernel tree)? [yes] " 0; then
if ! create_temp_kernel_tree; then
echo ""
echo "Unable to create temporary kernel tree"
kernelrebuild_instructions
return 1
fi
rm -f "${KERNELSRC}/include/linux/.config" \
"${KERNELSRC}/include/linux/autoconf.h" \
"${KERNELSRC}/include/linux/version.h"
if ! cp -p /boot/vmlinuz.autoconf.h "${KERNELSRC}/include/linux/autoconf.h" || \
! cp -p /boot/vmlinuz.version.h "${KERNELSRC}/include/linux/version.h"; then
echo ""
echo "Unable to copy files to temporary kernel tree"
remove_temp_kernel_tree
kernelrebuild_instructions
return 1
fi

# we don't really need .config but it can't hurt if available
if [ -f /boot/vmlinuz.config ]; then
cp -p /boot/vmlinuz.config "${KERNELSRC}/include/linux/.config"
fi
fi
fi
fi

# are we ok now?
if [ ! -f "${KERNELSRC}/include/linux/version.h" \
-o ! -f "${KERNELSRC}/include/linux/autoconf.h" ]; then
remove_temp_kernel_tree
kernelrebuild_instructions
return 1
fi

buildlogf=/tmp/hsfconfig-buildlog.txt

# set FILEKERNELVER if it isn't already
[ -n "${FILEKERNELVER}" ] || right_version_kernel_tree

check_kernel_config || return $?

echo ""
echo "Building modules for kernel ${FILEKERNELVER}, using source directory"
echo "${KERNELSRC}. Please wait…"

rm -f "${buildlogf}"
(cd ${cnxtlibdir}/modules && make "CNXT_KERNELSRC=${KERNELSRC}" clean minstall) &gt; ${buildlogf} 2&gt;&1
res=$?

(cd ${cnxtlibdir}/modules && make "CNXT_KERNELSRC=${KERNELSRC}" clean) &gt;/dev/null 2&gt;&1

remove_temp_kernel_tree

if [ $res -eq 0 ]; then
rm -f ${buildlogf}
return 0
else
echo ""
echo "ERROR: Module build failed!"
echo "Please examine the log file \"${buildlogf}\" to determine why."
return 1
fi
}

dcp_supported()
{
[ "hsf" = "hsf" ]
}

diag_supported()
{
true
}

old_scr_supported()
{
modinfo -p hsfosspec 2&gt;/dev/null | grep -q scrmajor
}

modules_exist()
{
files_present "/lib/modules/${OSKERNVERS}/misc/hsf"*.${KO} ||
files_present "/lib/modules/${OSKERNVERS}/extra/hsf"*.${KO}
}

remove_kernel_modules()
{
if modules_exist; then
echo ""
echo "Removing hsf driver from /lib/modules/${OSKERNVERS}/"
rm -f "/lib/modules/${OSKERNVERS}/misc/hsf"*.${KO}
rm -f "/lib/modules/${OSKERNVERS}/extra/hsf"*.${KO}
rm -f "/lib/modules/${OSKERNVERS}/extra/snd-hda-"*.${KO}
for m in snd-hda-intel snd-hda-codec; do
if [ -e "/lib/modules/${OSKERNVERS}/kernel/sound/pci/hda/${m}.${KO}.REPLACEDBYhsfmodem" -a ! -e \
"/lib/modules/${OSKERNVERS}/kernel/sound/pci/hda/${m}.${KO}" ]; then
mv -f "/lib/modules/${OSKERNVERS}/kernel/sound/pci/hda/${m}.${KO}.REPLACEDBYhsfmodem" "/lib/modules/${OSKERNVERS}/kernel/sound/pci/hda/${m}.${KO}"
fi
done
rm -f "/lib/modules/${OSKERNVERS}/extra/snd-hda-"*.${
Post #: 1
RE: скриптег... - 2006-11-10 00:03:31.896666   
BuriK666

Сообщений: 349
Оценки: 0
Присоединился: 2005-06-21 08:47:59
ты бы еще исходники Ядра сюда кинул.
Post #: 2
RE: скриптег... - 2006-11-10 00:04:31.756666   
TheFeaR

Сообщений: 1923
Оценки: 0
Присоединился: 2006-01-25 18:16:33
quote:

ORIGINAL: BuriK666

ты бы еще исходники Ядра сюда кинул.

ЖжОшЬ
Post #: 3
RE: скриптег... - 2006-11-10 01:09:10.693333   
Hvost

Сообщений: 150
Оценки: 0
Присоединился: 2005-01-09 22:47:56
quote:

кто помогет разобраться?
и километровый код….
буггага боян…
Post #: 4
RE: скриптег... - 2006-11-10 18:41:55.100000   
d0lph1n

Сообщений: 411
Оценки: 0
Присоединился: 2006-09-14 17:55:51.653333
За такие посты убивать надо
quote:

ты бы еще исходники Ядра сюда кинулю

Зря так говоришь, ведь выложит ))
Post #: 5
RE: скриптег... - 2006-11-10 19:52:16.320000   
rgo

Сообщений: 7170
Оценки: 281
Присоединился: 2004-09-25 05:14:25
2hladon
ты вот это читал? я сам не пробовал, но вроде там что-то было про это ограничение, и вроде как даже его отламывали ;)
Post #: 6
RE: скриптег... - 2006-11-10 20:15:18.130000   
rtw

Сообщений: 1372
Оценки: 0
Присоединился: 2004-08-19 00:28:05
у меня мазоль от скрола на пальце натёрлась!
Post #: 7
RE: скриптег... - 2006-11-10 21:56:14.943333   
hladon

Сообщений: 334
Оценки: 0
Присоединился: 2005-12-29 07:46:40
Блин, сюда же файлы нельзя прикреплять нельзя - вот и пришлось:)
Или может там в исходниках ядра проблема?[sm=14.gif]
Post #: 8
RE: скриптег... - 2006-11-10 22:25:03.006666   
hladon

Сообщений: 334
Оценки: 0
Присоединился: 2005-12-29 07:46:40
УрАААААА!:D:D:D
[sm=em121.gif]Слава крякерам буржуеВ![sm=em121.gif]
Post #: 9
RE: скриптег... - 2006-11-11 08:43:01.956666   
d0lph1n

Сообщений: 411
Оценки: 0
Присоединился: 2006-09-14 17:55:51.653333
Где кряку нашел? Признавайся! )
Post #: 10
RE: скриптег... - 2006-11-11 10:15:18.646666   
hladon

Сообщений: 334
Оценки: 0
Присоединился: 2005-12-29 07:46:40
см rgo;)
Post #: 11
Страниц:  [1]
Все форумы >> [*nix/Linux] >> скриптег...







Связаться:
Вопросы по сайту / xakep@glc.ru

Предупреждение: использование полученных знаний в противозаконных целях преследуется по закону.