update makesd
This commit is contained in:
Regular → Executable
+45
-5
@@ -30,7 +30,6 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
# =======================================================================
|
# =======================================================================
|
||||||
#
|
#
|
||||||
'''common installation'''
|
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import signal
|
import signal
|
||||||
@@ -161,10 +160,51 @@ def execute_wget(cmd, timeout=86400, cwd=None):
|
|||||||
print_process(process_str, True)
|
print_process(process_str, True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def C_trans_to_E(string):
|
||||||
|
E_PUN = u',.!?:[]()<>"\''
|
||||||
|
C_PUN = u',。!?:【】()《》“‘'
|
||||||
|
|
||||||
|
table= {ord(f):ord(t) for f,t in zip(C_PUN,E_PUN)}
|
||||||
|
|
||||||
|
return string.translate(table)
|
||||||
|
|
||||||
|
|
||||||
|
def remove_chn_and_charactor(str1):
|
||||||
|
C_PUN = u',。!?:【】()《》“‘'
|
||||||
|
stren = ''
|
||||||
|
|
||||||
|
if not isinstance(str1,str):
|
||||||
|
print("The input is not string")
|
||||||
|
return stren
|
||||||
|
|
||||||
|
for i in range(len(str1)):
|
||||||
|
if str1[i] >= u'\u4e00' and str1[i] <= u'\u9fa5' \
|
||||||
|
or str1[i] >= u'\u3300' and str1[i] <= u'\u33FF' \
|
||||||
|
or str1[i] >= u'\u3200' and str1[i] <= u'\u32FF' \
|
||||||
|
or str1[i] >= u'\u2700' and str1[i] <= u'\u27BF' \
|
||||||
|
or str1[i] >= u'\u2600' and str1[i] <= u'\u26FF' \
|
||||||
|
or str1[i] >= u'\uFE10' and str1[i] <= u'\uFE1F' \
|
||||||
|
or str1[i] >= u'\u2E80' and str1[i] <= u'\u2EFF' \
|
||||||
|
or str1[i] >= u'\u3000' and str1[i] <= u'\u303F' \
|
||||||
|
or str1[i] >= u'\u31C0' and str1[i] <= u'\u31EF' \
|
||||||
|
or str1[i] >= u'\u2FF0' and str1[i] <= u'\u2FFF' \
|
||||||
|
or str1[i] >= u'\u3100' and str1[i] <= u'\u312F' \
|
||||||
|
or str1[i] >= u'\u21A0' and str1[i] <= u'\u31BF' \
|
||||||
|
:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if str1[i] in C_PUN:
|
||||||
|
st = C_trans_to_E(str1[i])
|
||||||
|
else:
|
||||||
|
st = str1[i]
|
||||||
|
stren += st
|
||||||
|
|
||||||
|
return stren
|
||||||
|
|
||||||
def check_sd(dev_name):
|
def check_sd(dev_name):
|
||||||
ret, disk = execute(
|
ret, disk = execute(
|
||||||
"fdisk -l 2>/dev/null | grep \"Disk {dev_name}:\"".format(dev_name=dev_name))
|
"fdisk -l 2>/dev/null | grep \"Disk {dev_name}[::]\"".format(dev_name=dev_name))
|
||||||
|
disk[0] = remove_chn_and_charactor(disk[0])
|
||||||
if not ret or len(disk) > 1:
|
if not ret or len(disk) > 1:
|
||||||
print(
|
print(
|
||||||
"[ERROR] Can not get disk, please use fdisk -l to check available disk name!")
|
"[ERROR] Can not get disk, please use fdisk -l to check available disk name!")
|
||||||
@@ -184,10 +224,10 @@ def check_sd(dev_name):
|
|||||||
unchanged_disk_list.append(disk_name)
|
unchanged_disk_list.append(disk_name)
|
||||||
unchanged_disk = " ".join(unchanged_disk_list)
|
unchanged_disk = " ".join(unchanged_disk_list)
|
||||||
|
|
||||||
disk_size_str = disk[0].split(", ")[1]
|
disk_size_str = disk[0].split(",")[1]
|
||||||
disk_size_str = disk_size_str.split()[0]
|
disk_size_str = disk_size_str.split()[0]
|
||||||
disk_size = int(disk_size_str)
|
disk_size = int(disk_size_str)
|
||||||
|
print("disk %s size %d"%(dev_name, disk_size))
|
||||||
if dev_name not in unchanged_disk and disk_size >= MIN_DISK_SIZE:
|
if dev_name not in unchanged_disk and disk_size >= MIN_DISK_SIZE:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+7
-6
@@ -338,17 +338,17 @@ apt-get install net-tools -y
|
|||||||
echo \"make_sd_process: 25%\"
|
echo \"make_sd_process: 25%\"
|
||||||
|
|
||||||
mv /etc/apt/sources.list.bak /etc/apt/sources.list
|
mv /etc/apt/sources.list.bak /etc/apt/sources.list
|
||||||
|
echo \"recover source.list end\"
|
||||||
# 2. set username
|
# 2. set username
|
||||||
useradd -m \${username} -d /home/\${username} -s /bin/bash
|
useradd -m \${username} -d /home/\${username} -s /bin/bash
|
||||||
sed -i \"/^\${username}:/c\\\\\${password}\" /etc/shadow
|
sed -i \"/^\${username}:/c\\\\\${password}\" /etc/shadow
|
||||||
sed -i \"/^root:/c\\\\\${root_pwd}\" /etc/shadow
|
sed -i \"/^root:/c\\\\\${root_pwd}\" /etc/shadow
|
||||||
|
echo \"set username end\"
|
||||||
# 3. config host
|
# 3. config host
|
||||||
echo 'davinci-mini' > /etc/hostname
|
echo 'davinci-mini' > /etc/hostname
|
||||||
echo '127.0.0.1 localhost' > /etc/hosts
|
echo '127.0.0.1 localhost' > /etc/hosts
|
||||||
echo '127.0.1.1 davinci-mini' >> /etc/hosts
|
echo '127.0.1.1 davinci-mini' >> /etc/hosts
|
||||||
|
echo \"config host end\"
|
||||||
# 4. config ip
|
# 4. config ip
|
||||||
echo \"
|
echo \"
|
||||||
network:
|
network:
|
||||||
@@ -368,7 +368,7 @@ network:
|
|||||||
addresses: [${USB_CARD_DEFAULT_IP}/24]
|
addresses: [${USB_CARD_DEFAULT_IP}/24]
|
||||||
gateway4: ${NETWORK_CARD_GATEWAY}
|
gateway4: ${NETWORK_CARD_GATEWAY}
|
||||||
\" > /etc/netplan/01-netcfg.yaml
|
\" > /etc/netplan/01-netcfg.yaml
|
||||||
|
echo \"config network ok\"
|
||||||
# 5. auto-run minirc_cp.sh and minirc_sys_init.sh when start ubuntu
|
# 5. auto-run minirc_cp.sh and minirc_sys_init.sh when start ubuntu
|
||||||
echo \"#!/bin/sh -e
|
echo \"#!/bin/sh -e
|
||||||
#
|
#
|
||||||
@@ -395,13 +395,14 @@ cd /var/
|
|||||||
exit 0
|
exit 0
|
||||||
\" > /etc/rc.local
|
\" > /etc/rc.local
|
||||||
|
|
||||||
|
echo \"config rc.local ok\"
|
||||||
|
|
||||||
chmod 755 /etc/rc.local
|
chmod 755 /etc/rc.local
|
||||||
echo \"RuntimeMaxUse=50M\" >> /etc/systemd/journald.conf
|
echo \"RuntimeMaxUse=50M\" >> /etc/systemd/journald.conf
|
||||||
echo \"SystemMaxUse=50M\" >> /etc/systemd/journald.conf
|
echo \"SystemMaxUse=50M\" >> /etc/systemd/journald.conf
|
||||||
|
echo \"config journald ok\"
|
||||||
echo \"export LD_LIBRARY_PATH=/home/HwHiAiUser/Ascend/acllib/lib64\" >> /home/HwHiAiUser/.bashrc
|
echo \"export LD_LIBRARY_PATH=/home/HwHiAiUser/Ascend/acllib/lib64\" >> /home/HwHiAiUser/.bashrc
|
||||||
|
echo \"config bashrc ok\"
|
||||||
exit
|
exit
|
||||||
# end" > ${LogPath}squashfs-root/chroot_install.sh
|
# end" > ${LogPath}squashfs-root/chroot_install.sh
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user