This commit is contained in:
parent
684b07f172
commit
79b0890c53
15
platform/s3ip-sysfs/scripts/s3ip-sysfs.service
Normal file
15
platform/s3ip-sysfs/scripts/s3ip-sysfs.service
Normal file
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=s3ip sysfs service
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=root
|
||||
ExecStart=/usr/bin/s3ip_sysfs_tool.sh start
|
||||
ExecStop=/usr/bin/s3ip_sysfs_tool.sh stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
32
platform/s3ip-sysfs/scripts/s3ip_load.py
Executable file
32
platform/s3ip-sysfs/scripts/s3ip_load.py
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
import json
|
||||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.system("sudo rm -rf /sys_switch;sudo mkdir -p -m 777 /sys_switch")
|
||||
|
||||
with open('/etc/s3ip/s3ip_sysfs_conf.json', 'r') as jsonfile:
|
||||
json_string = json.load(jsonfile)
|
||||
for s3ip_sysfs_path in json_string['s3ip_syfs_paths']:
|
||||
#print('path:' + s3ip_sysfs_path['path'])
|
||||
#print('type:' + s3ip_sysfs_path['type'])
|
||||
#print('value:' + s3ip_sysfs_path['value'])
|
||||
|
||||
if s3ip_sysfs_path['type'] == "string" :
|
||||
(path, file) = os.path.split(s3ip_sysfs_path['path'])
|
||||
#创建文件
|
||||
command = "sudo mkdir -p -m 777 " + path
|
||||
#print(command)
|
||||
os.system(command)
|
||||
command = "sudo echo " + "\"" + s3ip_sysfs_path['value'] + "\"" + " > " + s3ip_sysfs_path['path']
|
||||
#print(command)
|
||||
os.system(command)
|
||||
elif s3ip_sysfs_path['type'] == "path" :
|
||||
command = "sudo ln -s " + s3ip_sysfs_path['value'] + " " + s3ip_sysfs_path['path']
|
||||
#print(command)
|
||||
os.system(command)
|
||||
else:
|
||||
print('error type:' + s3ip_sysfs_path['type'])
|
||||
os.system("tree -l /sys_switch")
|
||||
|
76
platform/s3ip-sysfs/scripts/s3ip_sysfs_conf.json
Normal file
76
platform/s3ip-sysfs/scripts/s3ip_sysfs_conf.json
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"s3ip_syfs_paths": [
|
||||
{
|
||||
"path": "/sys_switch/temp_sensor",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/temp_sensor",
|
||||
"description": "temperature information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/vol_sensor",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/vol_sensor",
|
||||
"description": "voltage sensor information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/syseeprom",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/syseeprom",
|
||||
"description": "ONIE EEPROM"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/fan",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/fan",
|
||||
"description": "fan information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/psu",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/psu",
|
||||
"description": "PSU information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/transceiver",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/transceiver",
|
||||
"description": "transceiver information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/sysled",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/sysled",
|
||||
"description": "SYS LED information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/fpga",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/fpga",
|
||||
"description": "FPGA information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/cpld",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/cpld",
|
||||
"description": "CPLD information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/watchdog",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/watchdog",
|
||||
"description": "watchdog information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/curr_sensor",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/curr_sensor",
|
||||
"description": "current sensor information"
|
||||
},
|
||||
{
|
||||
"path": "/sys_switch/slot",
|
||||
"type" : "path",
|
||||
"value" : "/sys/s3ip/slot",
|
||||
"description": "slot information"
|
||||
}
|
||||
]
|
||||
}
|
59
platform/s3ip-sysfs/scripts/s3ip_sysfs_tool.sh
Executable file
59
platform/s3ip-sysfs/scripts/s3ip_sysfs_tool.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#! /bin/bash
|
||||
|
||||
s3ip_start(){
|
||||
sudo insmod /lib/modules/s3ip/s3ip_sysfs.ko
|
||||
sudo insmod /lib/modules/s3ip/syseeprom_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/fan_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/cpld_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/sysled_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/psu_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/transceiver_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/temp_sensor_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/vol_sensor_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/fpga_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/watchdog_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/curr_sensor_device_driver.ko
|
||||
sudo insmod /lib/modules/s3ip/slot_device_driver.ko
|
||||
sudo rm -rf /sys_switch
|
||||
sudo /usr/bin/s3ip_load.py
|
||||
echo "s3ip service start"
|
||||
}
|
||||
s3ip_stop(){
|
||||
sudo rmmod slot_device_driver
|
||||
sudo rmmod curr_sensor_device_driver
|
||||
sudo rmmod watchdog_device_driver
|
||||
sudo rmmod fpga_device_driver
|
||||
sudo rmmod vol_sensor_device_driver
|
||||
sudo rmmod temp_sensor_device_driver
|
||||
sudo rmmod transceiver_device_driver
|
||||
sudo rmmod psu_device_driver
|
||||
sudo rmmod sysled_device_driver
|
||||
sudo rmmod cpld_device_driver
|
||||
sudo rmmod fan_device_driver
|
||||
sudo rmmod syseeprom_device_driver
|
||||
sudo rmmod s3ip_sysfs
|
||||
sudo rm -rf /sys_switch
|
||||
echo "s3ip service stop"
|
||||
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
s3ip_start
|
||||
;;
|
||||
stop)
|
||||
s3ip_stop
|
||||
;;
|
||||
status)
|
||||
sudo tree -l /sys_switch
|
||||
;;
|
||||
restart)
|
||||
s3ip_stop
|
||||
s3ip_start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|restart}"
|
||||
exit 1
|
||||
esac
|
||||
exit
|
||||
|
Loading…
Reference in New Issue
Block a user