Open main menu

Changes

XScript

6,565 bytes removed, 9 April
{{GD Template Impl}}
==Overview==__NOTOC__This page only provides scripts is script installation tutorial for [[NASPi]], [[NASPi Gemini 2.5]], [[NASPi CM4-M2]] and tutorial on how to install '''power management & safety switch & PWM fan''' based on different OS[[NASPi CM4-2. 5]]
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''':* This script also works on [https://www.raspberrypi.com/documentationsoftware/computersoperating-systems/getting-started.html Getting startedbookworm]* [https://wwwOS, and test it on Jan.raspberrypi9th 2024.com/documentation/computers/compute-module.html#flashing-the-compute-module-emmc Flashing the Compute Module eMMC]
==For Raspbian OS=='''Test this The original key pwm fan control script based on the following OS:'''* is from [https://downloadsgithub.raspberrypi.orgcom/raspios_arm64pimlie/images/raspios_arm64geekworm-2023-05x-03/2023-05-03-raspios-bullseye-arm64.img.xz 2023-05-03-raspios-bullseye-arm64.img.xz]* [https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2023-05-03/2023-05-03-raspios-bullseye-arm64-lite.img.xz 2023-05-03-raspios-bullseye-arm64-lite.img.xz]* [https://retropie.org.uk/download/ retropie-buster-4.8-rpi4_400.img.gz]* [https://twisteros.com/download.html TwisterOSv2-1-2.img.xz]===Install===<pre>cd ~sudo apt-get updatesudo apt-get -y upgradesudo apt-get -y install git i2c-tools python3-smbus python3-rpi.gpio git clone https://github.comc1 pimlie/geekworm-com/xscript.git cd xscriptsudo chmod +x *.shsudo cp -f ./pwr.sh /etc/pwr.shsudo cp -f ./softsd.sh /usr/local/bin/softsd.sh sudo sed c1], pimlie implements the pwm fan shell script, which does not depend on third-i '$ i /etc/pwrparty python libraries at all.sh &' /etc/rc.local echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/Thanks to pimlie.bashrc
sudo reboot now
</pre>
If Now we think you find have successfully flashed the following information when executing OS Image into Micro SD and and power on the above command:device, and you have also completed the operations such as creating new user required in some Raspberry Pi OS.
'''''0 upgradedAfter your system boots, 0 newly installedthen you need to open <code>Terminal</code> prpgram, 0 then type the following command to remove and 0 not upgraded.'''''complete the installation of the script
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.'''[Update]'''
1. NASPi series does '''not support Raspberry Pi 5 hardwared''' due to different hardware interface.
===Test safe shutdown=== xoff* Please run 'xoff' to shut down or press the on-board button switch to shut down2. <span style="color:red;">DON'T run the 'shutdown' linux command to shut down, otherwise the power Use gpiod instead of device will not be shut down.</span>* press button switch `1-2` seconds to reboot* press button switch `3` seconds to safe shutdownobsolete interface,* press `7-8` seconds to force shutdownand suuports ubuntu 23.04 also
===How to enable OLED display===Please refer to [[How to enable OLED display]] === PWM fan control3. The script now supports the Raspberry Pi OS '''BOOKWORM'' (This is optional)=== PS: You can ignore this step if you don't use the 3-Pin PWM fan to cool the CM4version. 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 You just need 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 uninstall''$ i python3 /home/pi/xscript/fan-rpi.py &' /etc/rc.localNOTE: Please make sure the fan-rpi.py file path is correct;  ===Uninstall=== sudo ./uninstall.sh sudo reboot now ==For ubuntu mate / ubuntun desktop / ubuntu server== Test this original script based on the following OS:* ubuntu-22.04.1-preinstalled-desktop-arm64+raspi.img.xz and '''Installreinstall'''it. Please refer to the following:
OPen ternimal window, then run the following command:
<pre>
cd ~sudo apt-get updatesudo apt-get upgrade mv xscript xcript-ysudo apt-get install -y git i2c-tools wiringpi python3-setuptools python3-distutils python3-rpi.gpio python3-smbusoldgit clone https://github.com/geekworm-com/xscript.git 
cd xscript
sudo chmod +x *.sh rc.localsudo cp -f ./pwr.sh /etc/pwr.shsudo cp -f ./softsd.sh /usr/local/bin/softsduninstall.sh #Enable rc.localsudo 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
</pre>
Then just follow the installation process below.
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 ==OS that your OS already contains these software, nothing more.has been tested==* RaspbianIf reboot fails, please force shutdown or power off and restart.* DietPi* Manjaro* Ubuntu (Testing based on ''' PWM fan controlUbuntu 23.04''' (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;* myNode* UmbrelBut when you reboot the device, the PWM fans won't run unless you run the above command again, * Volumio* RetroPieThere are '''serveral methods''' to enable fan run after the device reboots:* Twister
1. Create a crontab job, place the command 'python3 /home/geekworm/xscript/fan-rpi.py&' into 'Note:''' Not tested with '''Home Assistant''', for some reason, we are not able to upgrade and use the crontabHome Assistant to test, refer please pay attention to [[How check if there is any update in the future.(If you have successfully tested Home Assistant, welcome to add crontab job]]share your experience via email at: support@geekworm.com)
2==Preconfigured <code>config. Place txt</code>==To install pwm fan, first add <code>dtoverlay=pwm-2chan</code> to <code>/boot/firmware/config.txt</code> or <code>/boot/config.txt</code> under [all] or the running command into end of file and <code>reboot</code>: sudo nano /boot/firmware/config.txtSome OS's config.txt may be in the /etcboot/rc.local filedirectory, so that you can need to run the following command: sudo sed -i '$ i python3 nano /homeboot/geekwormconfig.txtUsing <code>ls /boot/xscriptfirmware/fan-rpiconfig.py&' txt</code> you can check if the file is in the /boot/etcfirmware/rc.local NOTE: You need change the 'geekworm' to your username;directory
'''Test safe shutdown'''Save & exit. xoffsudo reboot* Please run 'xoff' to shut down or press the on-board button switch to shut down. <span style="colorPS:red;">DON'T run the 'shutdown' linux command Only appending to shut down, otherwise the power of device will last line not be shut down.</span>* press button switch `1-2` seconds to reboot* press button switch `3` seconds to safe shutdown,* press `7-8` seconds to force shutdownreplace.
'''uninstall'''===Install gpiod package=== sudo ./uninstall.sh sudo reboot nowapt install -y gpiod
== For DietPiDownload the script==* [https://dietpi.com/#download DietPi_RPi-ARMv8-Bullseye.7z] '''Install''' login via teminal window, the default user name is `root`, password is `dietpi`, then run the following command:
<pre>
cd ~sudo apt-get updatesudo apt-get -y upgradesudo 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.localsudo cp -f ./pwr.sh /etc/pwr.shsudo 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.localecho "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrc sudo reboot now
</pre>
'''PS''': For some OS such as ''Raspberry Pi OS Lite'', the '''''git''''' tool is not installed by default, if you get an error like ''error: -bash: git: command not found'', please run the following command to install the git tool.
sudo apt install -y git
''' PWM ==Create the x-c1-fan control''' (This is optional)service==<span class="tb_red_bold"> Note: If your device does not support pwm fans or you are not using pwm, you can skip this step</span>
PS: You can ignore this step if you don't use Run the 3following command to install fan service script; sudo ./install-Pin PWM fan to cool the CM4-service. In fact, the [[C235]] passive cooler can provide enough cooling capacity, and you can also avoid shThen the trouble of pwm fan noise, it is included in [[NASPi CM4-M2]] and [[NASPi CM4-2starts running.5]]
Run ==Create the below command to get the fan running.x-c1-pwr service== python3 sudo ./root/xscript/faninstall-pwr-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]]service.sh
==Prepair software shutdown script==
sudo ./install-sss.sh
'''Test safe shutdown''' xoff* Please run 'After the installation is complete, an <code>xoff' to shut down or press the on-board button switch to shut down. <span style="color:red;"/code>DON'T run the 'shutdown' linux command will be created to shut down, otherwise the power of device will not be shut downsoftware.Then you can run <code>xoff</spancode>* press button switch `1-2` seconds to reboot* press button switch `3` seconds to safe shutdown,* press `7-8` seconds to force execute software shutdown.
'''==Uninstall==Run the following command to uninstall'''all.
sudo ./uninstall.sh
sudo reboot now
==For Manjaro==Test this script base on the following OS:* [https://manjaro.org Manjaro-ARM-gnome-rpi4-23.02.img.xz] ===1. Install=safe shutdown== '''Update system & install dependent packages''' cd ~ sudo pacman -Syyu sudo pacman -S python python-setuptools Software safe shutdown command'''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 '''Enable rc.local service''' sudo cp -f ./rc.local /etc/rc.local sudo cp rc.local.service /lib/systemd/system sudo systemctl enable rc.local  sudo sed -i '$ i /etc/pwr.sh &' /etc/rc.local sudo sed -i '$ i sudo python3 ~/xscript/fan-rpi.py &' /etc/rc.local '''Create a alias xoff''' echo "alias xoff='sudo /usr/local/bin/softsd.sh'" >> ~/.bashrcThen reboot the device sudo reboot now ===2. Test safe shutdown===
xoff
* Please run 'xoff' to shut down or press the on-board button switch to shut down. <span class="tb_red">DON'T run the 'shutdown' linux command to shut down, otherwise the power of device shield 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.</span>
===3. PWM fan control (Optional)==='''Hardware safe shutdown operation''':
PS: You can ignore this step if you don't use verify the 3-Pin PWM fan to cool safety switch through the CM4. In factonboard switch, press and hold the C235 passive cooler can provide enough cooling capacityswitch for <code>3</code> seconds, then the blue LED will flash slowly and you can also avoid the trouble of fan noise, it shutdown is going then all LEDs will be off until the device is included in [[NASPi CM4completely powered off.* press on-M2]] and [[NASPi CM4board button switch <code>1-2</code> seconds to reboot* press button switch <code>3</code> seconds to safe shutdown,* press <code>7-8</code> seconds to force shutdown.5]]
Run the below command to get ==Sample==#The code for fan speed control is now in the <code>x-c1-fan running.sh</code> file. sudo python3 ~/xscript#<code>fan-rpi.py</code> and <code>fan-rpipigpio.py &But when you reboot the device, the PWM fans won't run unless you run the above command again</code> are no longer used,and are reserved here for research and use by python lovers only.
ON Manjaro OS, Place the running command into the '/etc/rc.local file', then this command will be execute after the device reboot, you can run the following command: sudo sed -i '$ i echo "your password" | sudo -S python3 ~/xscript/fan-rpi.py &' /etc/rc.local==Support==NOTEEmail: Please make sure the fan-rpisupport@geekworm.py file path is correct;com
===4If you have any problems during use, please contact us by email and tell us the product model you are using and the OS version you are using. Uninstall=== cd ~/xscript sudo ./uninstall.sh sudo reboot now
==For myNode OS and UmbrelFAQ==* [https<html><details><summary>Q:How to login <b>volumio</b> via SSH?</mynodebtcsummary><p>1.comEnable SSH:</ mynode_raspi4_arm64_0-3-18.img.gz], the default user name is `'''admin'''`, default password is `'''bolt'''`p>* [https<p>Visit http://umbrelvolumio.comlocal/dev/, then click <b>ENABLE SSH</b> button</ umbrel-os-v0p><p>2.5.3.zip]URL connection is IP address,and the default user name is `'''umbrel'''`<b>volumio</b>, default password is `'''moneyprintergobrrr'''`<b>volumio</b></p></details>
===1<details><summary>Q: How to login to <b>Umbrel</b> via SSH?</summary>A: ssh umbrel@umbrel. Install===local (or ssh umbrel@<IP address of your Umbrel>). the default user name is <b>umbrel</b>, default password is <b>moneyprintergobrrr</b></details>
sudo apt-get update<details> sudo apt-get install pigpio python-pigpio python-smbus wiringpi -y cd ~ git clone https<summary>Q:How to login to <b>myNode</b> via SSH?</github.com/geekworm-com/xscript.git 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 sed -i '$ i /etc/pwr.sh &' /etc/rc.localsummary>
echo "alias xoff='sudo A: URL connection is IP address, and the default user name is <b>admin</usrb>, default password is <b>bolt</localb></bin/softsd.sh'" details>> ~/.bashrc
Then reboot the device<details> sudo reboot now<summary>Q: How to login to <b>DietPi</b> via SSH?</summary>
===2. 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 downA: URL connection is IP address, otherwise and the power of device will not be shut down.* press button switch `1-2` seconds to reboot* press button switch `3` seconds to safe shutdowndefault user name is <b>root</b>,default password is <b>dietpi</b>* press `7-8` seconds to force shutdown.</details>
===3. PWM fan control (Optional)===<details><summary>Q: Is <b>LibreELEC</b> supported?</summary>
PSA: 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]]TODO</details>
Run the below command to get the fan running. sudo systemctl enable pigpiod sudo sed -i '$ i sudo pigpiod' </etc/rc.local sudo python ~/xscript/fan.py &But when you reboot the device, the PWM fans won't run unless you run the above command again,html>
ON myNode OS, create a crontab,place the following command into the crontab file, then this command will be execute after the device reboot, refer to [[How to add crontab job]].
* * * * * python ~/xscript/fan.py &
NOTE: Please make sure the fan.py file path is correct;
<!--Add review function! -->