Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions platform/s3ip-sysfs/scripts/s3ip-sysfs.service
Original file line number Diff line number Diff line change
@@ -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 changes: 32 additions & 0 deletions platform/s3ip-sysfs/scripts/s3ip_load.py
Original file line number Diff line number Diff line change
@@ -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 changes: 76 additions & 0 deletions platform/s3ip-sysfs/scripts/s3ip_sysfs_conf.json
Original file line number Diff line number Diff line change
@@ -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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a platform drivers are already loaded and path to read fan_speed is
/sys/bus/i2c/devices/x-00y/fan<>_input

How can we mention this in the JSON file? Can you give an example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example you want is shown below,
{
"path": "/sys_switch/fan/fan1/motor0/speed",
"type" : "path",
"value" : "/sys/bus/i2c/devices/x-00y/fan<>_input",
"description": "the motor0 of fan1 speed information"
},

"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 changes: 59 additions & 0 deletions platform/s3ip-sysfs/scripts/s3ip_sysfs_tool.sh
Original file line number Diff line number Diff line change
@@ -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