提交 14cc8892 作者: bo.sun

Initial commit

上级 d8bcb5c3
#!/bin/bash
len=9
result=$(i2cget -y -f 3 0x50 0x0 i)
ascii_chars=$(echo "$result" | xxd -r -p)
serial=$(echo "$ascii_chars" | cut -c 1-"$len")
echo "$serial"
#!/bin/bash
case "$1" in
-w)
if [ $# -ne 4 ]; then
echo "错误:需要提供4个参数,当前参数数量为 $#"
echo "正确用法应该是: ./saturn-device-id.sh -w offsetaddress serialNo length"
exit 1
fi
input_address="$2"
input_string="$3"
input_length="$4"
hex_string=$(printf "%s" "$input_string" | xxd -p)
declare -a values
for ((i = 0; i < ${#hex_string}; i += 2)); do
two_chars="${hex_string:i:2}"
values+=("0x$two_chars")
done
i2cset_command="i2cset -y -f 3 0x50 $input_address"
for element in "${values[@]}"; do
i2cset_command="$i2cset_command $element"
done
i2cset_command="$i2cset_command i"
eval "$i2cset_command"
;;
-r)
if [ $# -ne 3 ]; then
echo "错误:需要提供3个参数,当前参数数量为 $#"
echo "正确用法应该是: ./saturn-device-id.sh -r offsetaddress length"
exit 1
fi
input_address="$2"
input_length="$3"
result=$(i2cget -y -f 3 0x50 $input_address i)
ascii_chars=$(echo "$result" | xxd -r -p)
serial=$(echo "$ascii_chars" | cut -c 1-"$input_length")
echo "$serial"
;;
*)
echo "参数错误 !!!"
echo "正确用法应该是:"
echo "./saturn-device-id.sh -w offsetaddress serialNo length"
echo "./saturn-device-id.sh -r offsetaddress length"
;;
esac
#!/bin/bash
IP=`echo $1|egrep -oc "^[^ ]([0-9]{1,3}\.){3}([0-9]{1,3})$"`
if [ ${IP} -eq 0 ];then
echo "请输入合规IP"
exit
else
echo "配置完成$1"
fi
if [ ! -f "/etc/systemd/network/10-enp3s0f0.network" ];then
echo "file not found!"
else
sed -i "s#Gateway.*#Gateway=${1}#" /etc/systemd/network/10-enp3s0f0.network
fi
......@@ -13,11 +13,10 @@ echo "配置完成$1"
fi
if [ -L "/etc/systemd/network/20-eth0.network" ] && [ -L "/etc/systemd/network/21-eth1.network" ];then
sed -i "s#Gateway.*#Gateway=${1}#" /opt/collect/20-eth0.network
if [ ! -f "/etc/systemd/network/20-eth0.network" ];then
echo "file not found"
else
sed -i "s#Gateway.*#Gateway=${1}#" /rootfs/etc/systemd/network/20-eth0.network
sed -i "s#Gateway.*#Gateway=${1}#" /etc/systemd/network/20-eth0.network
fi
sync
sync
......@@ -13,10 +13,9 @@ echo "配置完成$1"
fi
if [ -L "/etc/systemd/network/20-eth0.network" ] && [ -L "/etc/systemd/network/21-eth1.network" ];then
sed -i "s#Gateway.*#Gateway=${1}#" /opt/collect/21-eth1.network
if [ ! -f "/etc/systemd/network/21-eth1.network" ];then
echo "file not found!"
else
sed -i "s#Gateway.*#Gateway=${1}#" /rootfs/etc/systemd/network/21-eth1.network
sed -i "s#Gateway.*#Gateway=${1}#" /etc/systemd/network/21-eth1.network
fi
sync
sync
#!/bin/bash
function kill_process(){
ID=`ps -ef | grep $1 | grep -v grep | awk '{print $1}'`
#echo $ID
for id in $ID
do
kill -9 $id
echo "kill $id"
done
}
if [ $# -eq 1 ]
then
swapoff -a
kill_process ipfs
kill_process /opt/tool/saturn-monitor
kill_process /opt/tool/saturn-cycle-c
kill_process /opt/tool/saturn-collect
kill_process /opt/storage/log/system
systemctl stop minio
systemctl stop nfs-server
systemctl stop smb
systemctl stop tgtd
systemctl stop dev
if grep -qs /opt/storage /proc/mounts; then
umount /dev/LVM/lvdisk
lvremove /dev/LVM/lvdisk
vgremove LVM
pvremove /dev/sda1
pvremove /dev/sdb1
pvremove /dev/sdc1
pvremove /dev/sdd1
fi
umount /dev/sda1
umount /dev/sdb1
umount /dev/sdc1
......@@ -48,7 +17,7 @@ then
sleep 1
/opt/tool/saturn-device-id.sh -w 0x0 $1 9
/opt/tool/saturn-device-id.sh -w 0x0 $1 16
echo "yes" |parted /dev/sda mklabel gpt
echo "Ignore" | parted /dev/sda "mkpart primary ext4 2048s -1"
......@@ -65,9 +34,5 @@ then
sync
partprobe
else
echo "Usage:saturn-init-prev.sh device-id"
fi
echo "success"
......@@ -2,9 +2,9 @@
systemctl stop minio smb tgtd nfs-service minio-colony glusterd
umount /opt/storage/data{1..4}
umount /opt/storage/data1
md=$(lsblk |grep md|awk -F- '{print $2}'|awk '{print $1}'|head -n1)
md=$(cat /proc/mdstat|awk 'NR==2{print $1}')
if [ ${md} = 'md5' ];then
mdadm -S /dev/md5
......@@ -19,7 +19,7 @@ mdadm --misc --zero-superblock /dev/sdc1
mdadm --misc --zero-superblock /dev/sdb1
mdadm --misc --zero-superblock /dev/sda1
rm -rf /rootfs/etc/mdadm.conf
rm -rf /etc/mdadm.conf
echo 'success'
......@@ -15,21 +15,15 @@ parted /dev/sdd set 1 raid on
#set 1 lvm on
echo 'yes' |mdadm -C -v /dev/md5 -l5 -n4 /dev/sd[a-d]1
#mdadm -D /dev/md5
#if_md5
#md=$(mdadm -D /dev/md5 |grep raid5|tr -s ' '|awk -F: '{print $2}')
md="/dev/md5"
if [ ! -e "$md" ];then
echo "md5_not_found"
exit
fi
mdadm -Ds >> /rootfs/etc/mdadm.conf
mdadm -Ds >> /etc/mdadm.conf
sync
sync
sleep 2
sleep 1
#mkfs
echo "yes" |mkfs.ext4 /dev/md5
......
#!/bin/bash
IP=`echo $1|egrep -oc "^[^ ]([0-9]{1,3}\.){3}([0-9]{1,3})$"`
if [ ${IP} -eq 0 ];then
echo "请输入合规IP"
exit
else
echo "配置完成$1"
fi
if [ ! -f /etc/systemd/network/10-enp3s0f0.network ];then
echo "file not found"
else
sed -i "s#Address.*#Address=${1}/24#" /etc/systemd/network/10-enp3s0f0.network
fi
sleep 1
systemctl restart systemd-networkd
#!/bin/bash
IP=`echo $1|egrep -oc "^[^ ]([0-9]{1,3}\.){3}([0-9]{1,3})$"`
......@@ -13,16 +14,14 @@ echo "配置完成$1"
fi
if [ -L "/etc/systemd/network/20-eth0.network" ] && [ -L "/etc/systemd/network/21-eth1.network" ];then
sed -i "s#Address.*#Address=${1}/24#" /opt/collect/20-eth0.network
if [ ! -f /etc/systemd/network/20-eth0.network ];then
echo "file not found"
else
sed -i "s#Address.*#Address=${1}/24#" /rootfs/etc/systemd/network/20-eth0.network
fi
sed -i "s#Address.*#Address=${1}/24#" /etc/systemd/network/20-eth0.network
sync
sync
sync
fi
sleep 1
systemctl restart systemd-networkd
......@@ -13,15 +13,12 @@ echo "配置完成$1"
fi
if [ -L "/etc/systemd/network/20-eth0.network" ] && [ -L "/etc/systemd/network/21-eth1.network" ];then
sed -i "s#Address.*#Address=${1}/24#" /opt/collect/21-eth1.network
if [ ! -f /etc/systemd/network/21-eth1.network ];then
echo "file not found"
else
sed -i "s#Address.*#Address=${1}/24#" /rootfs/etc/systemd/network/21-eth1.network
fi
sed -i "s#Address.*#Address=${1}/24#" /etc/systemd/network/21-eth1.network
sync
sync
sync
fi
sleep 1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论