Difference between revisions of "XScript"
Line 191: | Line 191: | ||
====install==== | ====install==== | ||
− | + | '''Update system & install dependent packages''' | |
cd ~ | cd ~ | ||
sudo pacman -Syyu | sudo pacman -Syyu | ||
sudo pacman -S python python-setuptools | sudo pacman -S python python-setuptools | ||
− | + | '''Install RPi.GPIO Python Library''' | |
+ | |||
The script that the fan runs depends on the RPi.GPIO Python library. Since this OS does not include this package by default, we need to install it manually. | The script that the fan runs depends on the RPi.GPIO Python library. Since this OS does not include this package by default, we need to install it manually. | ||
Refer to [[How to Install RPi.GPIO Python Library]], and you need use the ''''Method 2 – Manual Installation'''' | Refer to [[How to Install RPi.GPIO Python Library]], and you need use the ''''Method 2 – Manual Installation'''' | ||
− | + | '''Download script''' | |
cd ~ | cd ~ | ||
git clone https://github.com/geekworm-com/xscript.git | git clone https://github.com/geekworm-com/xscript.git | ||
Line 208: | Line 209: | ||
sudo pacman -S git | sudo pacman -S git | ||
− | + | '''Install script''' | |
cd ~/xscript | cd ~/xscript | ||
sudo chmod +x *.sh rc.local | sudo chmod +x *.sh rc.local | ||
Line 218: | Line 219: | ||
sudo sed -i '$ i sudo python3 ~/xscript/fan.py &' /etc/rc.local | sudo sed -i '$ i sudo python3 ~/xscript/fan.py &' /etc/rc.local | ||
− | Create a alias xoff | + | '''Create a alias xoff''' |
echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc | echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc | ||
Then reboot the device | Then reboot the device |
Revision as of 11:46, 17 June 2023
Contents
Overview
This page only provides scripts on how to install power management & safety switch & PWM fan based on different OS.
If you need to know how to flash raspberry pi OS image into micro sd card or nvme ssd, please refer to the following official document:
For Raspbian OS
Test this script based on the following OS:
- 2023-05-03-raspios-bullseye-arm64.img.xz
- 2023-05-03-raspios-bullseye-arm64-lite.img.xz
- retropie-buster-4.8-rpi4_400.img.gz
- TwisterOSv2-1-2.img.xz
Install
cd ~ sudo apt-get update sudo apt-get -y upgrade sudo apt-get -y install git i2c-tools python3-smbus python3-rpi.gpio git clone https://github.com/geekworm-com/xscript.git cd xscript sudo chmod +x *.sh sudo cp -f ./pwr.sh /etc/pwr.sh sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc sudo reboot now
If you find the following information when executing the above command:
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Please ignore it, it just means that your OS already contains these software, nothing more.
If reboot fails, please force shutdown or power off and restart.
PWM fan control (This is optional)
PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the C235 passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in NASPi CM4-M2 and NASPi CM4-2.5
Run the below command to get the fan running.
python3 /home/pi/xscript/fan-rpi.py &
But when you reboot the device, the PWM fans won't run unless you run the above command again,
There are serveral methods to enable fan run after the device reboots, recommend the first method:
1. Create a crontab job, place the command 'python3 /home/geekworm/xscript/fan-rpi.py&' into the crontab, refer to How to add crontab job.
2. Place the running command into the /etc/rc.local file, you can run the following command:
sudo sed -i '$ i python3 /home/pi/xscript/fan-rpi.py &' /etc/rc.local
NOTE: Please make sure the fan-rpi.py file path is correct;
Test safe shutdown
xoff
- Please run 'xoff' to shut down or press the on-board button switch to shut down. DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.
- press button switch `1-2` seconds to reboot
- press button switch `3` seconds to safe shutdown,
- press `7-8` seconds to force shutdown.
uninstall
sudo ./uninstall.sh sudo reboot now
For ubuntu mate / ubuntun desktop / ubuntu server
est this script based on the following OS:
- ubuntu-22.04.1-preinstalled-desktop-arm64+raspi.img.xz
Install
cd ~ sudo apt-get update sudo apt-get upgrade -y sudo apt-get install -y git i2c-tools wiringpi python3-setuptools python3-distutils python3-rpi.gpio python3-smbus git clone https://github.com/geekworm-com/xscript.git cd xscript sudo chmod +x *.sh rc.local sudo cp -f ./pwr.sh /etc/pwr.sh sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh #Enable rc.local sudo cp -f ./rc.local /etc/rc.local sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc sudo reboot now
If you find the following information when executing the above command:
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Please ignore it, it just means that your OS already contains these software, nothing more.
If reboot fails, please force shutdown or power off and restart.
PWM fan control (This is optional)
PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the C235 passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in NASPi CM4-M2 and NASPi CM4-2.5
Run the below command to get the fan running.
python3 /home/geekworm/xscript/fan-rpi.py&
NOTE: You need change the 'geekworm' to your username;
But when you reboot the device, the PWM fans won't run unless you run the above command again,
There are serveral methods to enable fan run after the device reboots:
1. Create a crontab job, place the command 'python3 /home/geekworm/xscript/fan-rpi.py&' into the crontab, refer to How to add crontab job.
2. Place the running command into the /etc/rc.local file, you can run the following command:
sudo sed -i '$ i python3 /home/geekworm/xscript/fan-rpi.py&' /etc/rc.local NOTE: You need change the 'geekworm' to your username;
Test safe shutdown
xoff
- Please run 'xoff' to shut down or press the on-board button switch to shut down. DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.
- press button switch `1-2` seconds to reboot
- press button switch `3` seconds to safe shutdown,
- press `7-8` seconds to force shutdown.
uninstall
sudo ./uninstall.sh sudo reboot now
For DietPi
Install
login via teminal window, the default user name is `root`, password is `dietpi`, then run the following command:
cd ~ sudo apt-get update sudo apt-get -y upgrade sudo apt-get -y install git i2c-tools python3 python3-smbus python3-rpi.gpio git clone https://github.com/geekworm-com/xscript.git cd xscript sudo chmod +x *.sh rc.local sudo cp -f ./pwr.sh /etc/pwr.sh sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh sudo cp -f ./rc.local /etc/rc.local sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc sudo reboot now
PWM fan control (This is optional)
PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4. In fact, the C235 passive cooler can provide enough cooling capacity, and you can also avoid the trouble of fan noise, it is included in NASPi CM4-M2 and NASPi CM4-2.5
Run the below command to get the fan running.
python3 /root/xscript/fan-rpi.py&
But when you reboot the device, the PWM fans won't run unless you run the above command again, so you need to create a crontab job to keep the fans running when the device reboots, Please refer to How to add crontab job.
Test safe shutdown
xoff
- Please run 'xoff' to shut down or press the on-board button switch to shut down. DON'T run the 'shutdown' linux command to shut down, otherwise the power of device will not be shut down.
- press button switch `1-2` seconds to reboot
- press button switch `3` seconds to safe shutdown,
- press `7-8` seconds to force shutdown.
uninstall
sudo ./uninstall.sh sudo reboot now
For Manjaro
install
Update system & install dependent packages
cd ~ sudo pacman -Syyu sudo pacman -S python python-setuptools
Install RPi.GPIO Python Library
The script that the fan runs depends on the RPi.GPIO Python library. Since this OS does not include this package by default, we need to install it manually.
Refer to How to Install RPi.GPIO Python Library, and you need use the 'Method 2 – Manual Installation'
Download script
cd ~ git clone https://github.com/geekworm-com/xscript.git
If the current OS does not include the git tool, then you need to use the following command to install it firstly
sudo pacman -S git
Install script
cd ~/xscript sudo chmod +x *.sh rc.local sudo cp -f ./pwr.sh /etc/pwr.sh sudo cp -f ./softsd.sh /usr/local/bin/softsd.sh sudo cp -f ./rc.local /etc/rc.local
sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local sudo sed -i '$ i sudo python3 ~/xscript/fan.py &' /etc/rc.local
Create a alias xoff
echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc
Then reboot the device
sudo reboot now
Enable comment auto-refresher
Anonymous user #24
Permalink |
Anonymous user #24
Lisa
Anonymous user #24
Permalink |
Lisa
Anonymous user #25
Anonymous user #23
Permalink |
Anonymous user #22
Permalink |
Lisa
Anonymous user #20
Permalink |
Anonymous user #21
Anonymous user #19
Permalink |
Anonymous user #18
Permalink |
Harry
Anonymous user #17
Permalink |
Harry
Anonymous user #16
Permalink |
Harry
Anonymous user #9
Permalink |
Anonymous user #9
Permalink |
Anonymous user #14
Permalink |
Anonymous user #13
Permalink |
Walker
Anonymous user #11
Permalink |
Anonymous user #11
Walker
Anonymous user #14
Anonymous user #10
Permalink |
Walker
Anonymous user #9
Permalink |
Anonymous user #9
Walker
Anonymous user #8
Permalink |
Walker
Anonymous user #15
Anonymous user #7
Permalink |
Anonymous user #7
Walker
Anonymous user #6
Permalink |
Harry
Anonymous user #5
Permalink |
Harry
Anonymous user #4
Permalink |
Walker
Anonymous user #12
Anonymous user #3
Permalink |
Harry
Anonymous user #3
Permalink |
Harry
Anonymous user #2
Permalink |
Harry
Anonymous user #2
Anonymous user #2
Anonymous user #1
Permalink |
Harry