- Messages
- 127
- Reaction score
- 1
- Points
- 28
# cat /sbin/wimax_cert_update.sh
#!/bin/sh
# @author Shane
#
# Derived from platform_update.sh
#
#
error_exit()
{
rm -f /var/wimax_cert_update.lock
exit 1
}
if [ -f /var/wimax_cert_update.lock ]; then
echo "wimax_cert_update is locked"
exit 1
fi
touch /var/wimax_cert_update.lock
if [ "$1" == "" ] ; then
echo "Usage : $0 [file | http url | tftp url]"
error_exit
fi
argv=$@
cat /etc/tmp/cert/wmx_client_ca1.pem
image_tar="/tmp/wimax_cert"
image_client_ca1="wmx_client_ca1.pem"
image_root_ca1="wmx_root_ca1.pem"
image_priv_key1="wmx_priv_key1.key"
image_client_ca2="wmx_client_ca2.pem"
image_root_ca2="wmx_root_ca2.pem"
image_priv_key2="wmx_priv_key2.key"
client_ca="wmx_client_ca.pem"
root_ca="wmx_root_ca.pem"
priv_key="wmx_priv_key.key"
tmp_cert_dir="/etc/tmp/cert"
cert_dir_loc="/etc"
cert_dir="/etc/cert"
log_file="/var/log/wimax_cert_update"
http=`echo $argv | grep "^http"`
tftp=`echo $argv | grep "^tftp://"`
mkdir -p $tmp_cert_dir
mkdir -p $cert_dir
if [ -n "$http" ] ; then
echo "<< HTTP mode >>"
echo "-----------------------------------------"
rm -rf ${image_tar}
echo -n "Download WiMAX Certificate ... "
rm -rf ${log_file}
wget --timeout=10 ${argv} -O ${image_tar} -q 2>${log_file}
ret=$?
if [ $ret == 0 ] ; then
echo "OK"
else
ret=`cat ${log_file}`
echo "Failed ($ret)"
error_exit
fi
elif [ -n "$tftp" ] ; then
echo "<< TFTP mode >>"
file=$argv
file=${file#*/}
file=${file#*/}
path=${file#*/}
addr=${file%%/*}
echo "Server address : $addr"
echo "Image path : $path"
echo "-----------------------------------------"
echo -n "Download WiMAX Certificate ... "
tftp -g -r "$path" -l $image_tar $addr 2>${log_file}
ret=$?
if [ $ret == 0 ] ; then
echo "OK"
else
ret=`cat ${log_file}`
echo "Failed ($ret)"
error_exit
fi
else
echo "<< FILE mode >>"
echo "File name : $argv"
echo "-----------------------------------------"
if [ -f $argv ] ; then
image_tar=$argv
else
echo "File not exist ... Failed"
error_exit
fi
fi
echo -n "Upgrade WiMAX Certification ... "
mv $image_tar $tmp_cert_dir/$root_ca
mv -f $tmp_cert_dir/* $cert_dir
if [ -f $cert_dir/$root_ca ]; then
rm -f $cert_dir_loc/$root_ca
ln -s $cert_dir/$root_ca $cert_dir_loc/$root_ca
fi
#tar zxf $image_tar -C $tmp_cert_dir
#if [ -f $cert_dir/$image_client_ca1 ]; then
# rm -f $cert_dir_loc/$client_ca
# ln -s $cert_dir/$image_client_ca1 $cert_dir_loc/$client_ca
#fi
#if [ -f $cert_dir/$image_root_ca1 ]; then
# rm -f $cert_dir_loc/$root_ca
# ln -s $cert_dir/$image_root_ca1 $cert_dir_loc/$root_ca
#fi
#if [ -f $cert_dir/$image_priv_key1 ]; then
# rm -f $cert_dir_loc/$priv_key
# ln -s $cert_dir/$image_priv_key1 $cert_dir_loc/$priv_key
#fi
echo "OK"
rm -f /var/wimax_cert_update.lock
if [ $? == 0 ] ; then
echo "OK"
if ! [ $NO_REBOOT == 1 ]; then
reboot
fi
else
echo "Failed"
echo "Reason : "
cat ${log_file}
fi
#
baka mayroon may idea
#!/bin/sh
# @author Shane
#
# Derived from platform_update.sh
#
#
error_exit()
{
rm -f /var/wimax_cert_update.lock
exit 1
}
if [ -f /var/wimax_cert_update.lock ]; then
echo "wimax_cert_update is locked"
exit 1
fi
touch /var/wimax_cert_update.lock
if [ "$1" == "" ] ; then
echo "Usage : $0 [file | http url | tftp url]"
error_exit
fi
argv=$@
cat /etc/tmp/cert/wmx_client_ca1.pem
image_tar="/tmp/wimax_cert"
image_client_ca1="wmx_client_ca1.pem"
image_root_ca1="wmx_root_ca1.pem"
image_priv_key1="wmx_priv_key1.key"
image_client_ca2="wmx_client_ca2.pem"
image_root_ca2="wmx_root_ca2.pem"
image_priv_key2="wmx_priv_key2.key"
client_ca="wmx_client_ca.pem"
root_ca="wmx_root_ca.pem"
priv_key="wmx_priv_key.key"
tmp_cert_dir="/etc/tmp/cert"
cert_dir_loc="/etc"
cert_dir="/etc/cert"
log_file="/var/log/wimax_cert_update"
http=`echo $argv | grep "^http"`
tftp=`echo $argv | grep "^tftp://"`
mkdir -p $tmp_cert_dir
mkdir -p $cert_dir
if [ -n "$http" ] ; then
echo "<< HTTP mode >>"
echo "-----------------------------------------"
rm -rf ${image_tar}
echo -n "Download WiMAX Certificate ... "
rm -rf ${log_file}
wget --timeout=10 ${argv} -O ${image_tar} -q 2>${log_file}
ret=$?
if [ $ret == 0 ] ; then
echo "OK"
else
ret=`cat ${log_file}`
echo "Failed ($ret)"
error_exit
fi
elif [ -n "$tftp" ] ; then
echo "<< TFTP mode >>"
file=$argv
file=${file#*/}
file=${file#*/}
path=${file#*/}
addr=${file%%/*}
echo "Server address : $addr"
echo "Image path : $path"
echo "-----------------------------------------"
echo -n "Download WiMAX Certificate ... "
tftp -g -r "$path" -l $image_tar $addr 2>${log_file}
ret=$?
if [ $ret == 0 ] ; then
echo "OK"
else
ret=`cat ${log_file}`
echo "Failed ($ret)"
error_exit
fi
else
echo "<< FILE mode >>"
echo "File name : $argv"
echo "-----------------------------------------"
if [ -f $argv ] ; then
image_tar=$argv
else
echo "File not exist ... Failed"
error_exit
fi
fi
echo -n "Upgrade WiMAX Certification ... "
mv $image_tar $tmp_cert_dir/$root_ca
mv -f $tmp_cert_dir/* $cert_dir
if [ -f $cert_dir/$root_ca ]; then
rm -f $cert_dir_loc/$root_ca
ln -s $cert_dir/$root_ca $cert_dir_loc/$root_ca
fi
#tar zxf $image_tar -C $tmp_cert_dir
#if [ -f $cert_dir/$image_client_ca1 ]; then
# rm -f $cert_dir_loc/$client_ca
# ln -s $cert_dir/$image_client_ca1 $cert_dir_loc/$client_ca
#fi
#if [ -f $cert_dir/$image_root_ca1 ]; then
# rm -f $cert_dir_loc/$root_ca
# ln -s $cert_dir/$image_root_ca1 $cert_dir_loc/$root_ca
#fi
#if [ -f $cert_dir/$image_priv_key1 ]; then
# rm -f $cert_dir_loc/$priv_key
# ln -s $cert_dir/$image_priv_key1 $cert_dir_loc/$priv_key
#fi
echo "OK"
rm -f /var/wimax_cert_update.lock
if [ $? == 0 ] ; then
echo "OK"
if ! [ $NO_REBOOT == 1 ]; then
reboot
fi
else
echo "Failed"
echo "Reason : "
cat ${log_file}
fi
#
baka mayroon may idea