Advertisement
Guest User

Untitled

a guest
Aug 10th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.13 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. argon_create_file() {
  5. if [ -f $1 ]; then
  6. sudo rm $1
  7. fi
  8. sudo touch $1
  9. sudo chmod 666 $1
  10. }
  11. argon_check_pkg() {
  12. RESULT=$(dpkg-query -W -f='${Status}\n' "$1" 2> /dev/null | grep "installed")
  13.  
  14. if [ "" == "$RESULT" ]; then
  15. echo "NG"
  16. else
  17. echo "OK"
  18. fi
  19. }
  20.  
  21. pkglist=(raspi-gpio python-rpi.gpio python3-rpi.gpio python-smbus python3-smbus i2c-tools)
  22. for curpkg in ${pkglist[@]}; do
  23. sudo apt-get install -y $curpkg
  24. RESULT=$(argon_check_pkg "$curpkg")
  25. if [ "NG" == "$RESULT" ]
  26. then
  27. echo "********************************************************************"
  28. echo "Please also connect device to the internet and restart installation."
  29. echo "********************************************************************"
  30. exit
  31. fi
  32. done
  33.  
  34.  
  35.  
  36. daemonname="argononed"
  37. powerbuttonscript=/usr/bin/$daemonname.py
  38. shutdownscript="/lib/systemd/system-shutdown/"$daemonname"-poweroff.py"
  39. daemonconfigfile=/etc/$daemonname.conf
  40. configscript=/usr/bin/argonone-config
  41. removescript=/usr/bin/argonone-uninstall
  42.  
  43. daemonfanservice=/lib/systemd/system/$daemonname.service
  44.  
  45. sudo raspi-config nonint do_i2c 0
  46. sudo raspi-config nonint do_serial 0
  47.  
  48. if [ ! -f $daemonconfigfile ]; then
  49. # Generate config file for fan speed
  50. sudo touch $daemonconfigfile
  51. sudo chmod 666 $daemonconfigfile
  52. echo '#' >> $daemonconfigfile
  53. echo '# Argon One Fan Configuration' >> $daemonconfigfile
  54. echo '#' >> $daemonconfigfile
  55. echo '# List below the temperature (Celsius) and fan speed (in percent) pairs' >> $daemonconfigfile
  56. echo '# Use the following form:' >> $daemonconfigfile
  57. echo '# min.temperature=speed' >> $daemonconfigfile
  58. echo '#' >> $daemonconfigfile
  59. echo '# Example:' >> $daemonconfigfile
  60. echo '# 55=10' >> $daemonconfigfile
  61. echo '# 60=55' >> $daemonconfigfile
  62. echo '# 65=100' >> $daemonconfigfile
  63. echo '#' >> $daemonconfigfile
  64. echo '# Above example sets the fan speed to' >> $daemonconfigfile
  65. echo '#' >> $daemonconfigfile
  66. echo '# NOTE: Lines begining with # are ignored' >> $daemonconfigfile
  67. echo '#' >> $daemonconfigfile
  68. echo '# Type the following at the command line for changes to take effect:' >> $daemonconfigfile
  69. echo '# sudo systemctl restart '$daemonname'.service' >> $daemonconfigfile
  70. echo '#' >> $daemonconfigfile
  71. echo '# Start below:' >> $daemonconfigfile
  72. echo '55=10' >> $daemonconfigfile
  73. echo '60=55' >> $daemonconfigfile
  74. echo '65=100' >> $daemonconfigfile
  75. fi
  76.  
  77. # Generate script that runs every shutdown event
  78. argon_create_file $shutdownscript
  79.  
  80. echo "#!/usr/bin/python" >> $shutdownscript
  81. echo 'import sys' >> $shutdownscript
  82. echo 'import smbus' >> $shutdownscript
  83. echo 'import RPi.GPIO as GPIO' >> $shutdownscript
  84. echo 'rev = GPIO.RPI_REVISION' >> $shutdownscript
  85. echo 'if rev == 2 or rev == 3:' >> $shutdownscript
  86. echo ' bus = smbus.SMBus(1)' >> $shutdownscript
  87. echo 'else:' >> $shutdownscript
  88. echo ' bus = smbus.SMBus(0)' >> $shutdownscript
  89.  
  90. echo 'if len(sys.argv)>1:' >> $shutdownscript
  91. echo " bus.write_byte(0x1a,0)" >> $shutdownscript
  92. echo ' if sys.argv[1] == "poweroff" or sys.argv[1] == "halt":' >> $shutdownscript
  93. echo " try:" >> $shutdownscript
  94. echo " bus.write_byte(0x1a,0xFF)" >> $shutdownscript
  95. echo " except:" >> $shutdownscript
  96. echo " rev=0" >> $shutdownscript
  97. sudo chmod 755 $shutdownscript
  98.  
  99. # Generate script to monitor shutdown button
  100.  
  101. argon_create_file $powerbuttonscript
  102.  
  103. echo "#!/usr/bin/python" >> $powerbuttonscript
  104. echo 'import smbus' >> $powerbuttonscript
  105. echo 'import RPi.GPIO as GPIO' >> $powerbuttonscript
  106. echo 'import os' >> $powerbuttonscript
  107. echo 'import time' >> $powerbuttonscript
  108. echo 'from threading import Thread' >> $powerbuttonscript
  109. echo 'rev = GPIO.RPI_REVISION' >> $powerbuttonscript
  110. echo 'if rev == 2 or rev == 3:' >> $powerbuttonscript
  111. echo ' bus = smbus.SMBus(1)' >> $powerbuttonscript
  112. echo 'else:' >> $powerbuttonscript
  113. echo ' bus = smbus.SMBus(0)' >> $powerbuttonscript
  114.  
  115. echo 'GPIO.setwarnings(False)' >> $powerbuttonscript
  116. echo 'GPIO.setmode(GPIO.BCM)' >> $powerbuttonscript
  117. echo 'shutdown_pin=4' >> $powerbuttonscript
  118. echo 'GPIO.setup(shutdown_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)' >> $powerbuttonscript
  119.  
  120. echo 'def shutdown_check():' >> $powerbuttonscript
  121. echo ' while True:' >> $powerbuttonscript
  122. echo ' pulsetime = 1' >> $powerbuttonscript
  123. echo ' GPIO.wait_for_edge(shutdown_pin, GPIO.RISING)' >> $powerbuttonscript
  124. echo ' time.sleep(0.01)' >> $powerbuttonscript
  125. echo ' while GPIO.input(shutdown_pin) == GPIO.HIGH:' >> $powerbuttonscript
  126. echo ' time.sleep(0.01)' >> $powerbuttonscript
  127. echo ' pulsetime += 1' >> $powerbuttonscript
  128. echo ' if pulsetime >=2 and pulsetime <=3:' >> $powerbuttonscript
  129. echo ' os.system("reboot")' >> $powerbuttonscript
  130. echo ' elif pulsetime >=4 and pulsetime <=5:' >> $powerbuttonscript
  131. echo ' os.system("shutdown now -h")' >> $powerbuttonscript
  132.  
  133. echo 'def get_fanspeed(tempval, configlist):' >> $powerbuttonscript
  134. echo ' for curconfig in configlist:' >> $powerbuttonscript
  135. echo ' curpair = curconfig.split("=")' >> $powerbuttonscript
  136. echo ' tempcfg = float(curpair[0])' >> $powerbuttonscript
  137. echo ' fancfg = int(float(curpair[1]))' >> $powerbuttonscript
  138. echo ' if tempval >= tempcfg:' >> $powerbuttonscript
  139. echo ' return fancfg' >> $powerbuttonscript
  140. echo ' return 0' >> $powerbuttonscript
  141.  
  142. echo 'def load_config(fname):' >> $powerbuttonscript
  143. echo ' newconfig = []' >> $powerbuttonscript
  144. echo ' try:' >> $powerbuttonscript
  145. echo ' with open(fname, "r") as fp:' >> $powerbuttonscript
  146. echo ' for curline in fp:' >> $powerbuttonscript
  147. echo ' if not curline:' >> $powerbuttonscript
  148. echo ' continue' >> $powerbuttonscript
  149. echo ' tmpline = curline.strip()' >> $powerbuttonscript
  150. echo ' if not tmpline:' >> $powerbuttonscript
  151. echo ' continue' >> $powerbuttonscript
  152. echo ' if tmpline[0] == "#":' >> $powerbuttonscript
  153. echo ' continue' >> $powerbuttonscript
  154. echo ' tmppair = tmpline.split("=")' >> $powerbuttonscript
  155. echo ' if len(tmppair) != 2:' >> $powerbuttonscript
  156. echo ' continue' >> $powerbuttonscript
  157. echo ' tempval = 0' >> $powerbuttonscript
  158. echo ' fanval = 0' >> $powerbuttonscript
  159. echo ' try:' >> $powerbuttonscript
  160. echo ' tempval = float(tmppair[0])' >> $powerbuttonscript
  161. echo ' if tempval < 0 or tempval > 100:' >> $powerbuttonscript
  162. echo ' continue' >> $powerbuttonscript
  163. echo ' except:' >> $powerbuttonscript
  164. echo ' continue' >> $powerbuttonscript
  165. echo ' try:' >> $powerbuttonscript
  166. echo ' fanval = int(float(tmppair[1]))' >> $powerbuttonscript
  167. echo ' if fanval < 0 or fanval > 100:' >> $powerbuttonscript
  168. echo ' continue' >> $powerbuttonscript
  169. echo ' except:' >> $powerbuttonscript
  170. echo ' continue' >> $powerbuttonscript
  171. echo ' newconfig.append( "{:5.1f}={}".format(tempval,fanval))' >> $powerbuttonscript
  172. echo ' if len(newconfig) > 0:' >> $powerbuttonscript
  173. echo ' newconfig.sort(reverse=True)' >> $powerbuttonscript
  174. echo ' except:' >> $powerbuttonscript
  175. echo ' return []' >> $powerbuttonscript
  176. echo ' return newconfig' >> $powerbuttonscript
  177.  
  178. echo 'def temp_check():' >> $powerbuttonscript
  179. echo ' fanconfig = ["65=100", "60=55", "55=10"]' >> $powerbuttonscript
  180. echo ' tmpconfig = load_config("'$daemonconfigfile'")' >> $powerbuttonscript
  181. echo ' if len(tmpconfig) > 0:' >> $powerbuttonscript
  182. echo ' fanconfig = tmpconfig' >> $powerbuttonscript
  183. echo ' address=0x1a' >> $powerbuttonscript
  184. echo ' prevblock=0' >> $powerbuttonscript
  185. echo ' while True:' >> $powerbuttonscript
  186. echo ' temp = os.popen("vcgencmd measure_temp").readline()' >> $powerbuttonscript
  187. echo ' temp = temp.replace("temp=","")' >> $powerbuttonscript
  188. echo ' val = float(temp.replace("'"'"'C",""))' >> $powerbuttonscript
  189. echo ' block = get_fanspeed(val, fanconfig)' >> $powerbuttonscript
  190. echo ' if block < prevblock:' >> $powerbuttonscript
  191. echo ' time.sleep(30)' >> $powerbuttonscript
  192. echo ' prevblock = block' >> $powerbuttonscript
  193. echo ' try:' >> $powerbuttonscript
  194. echo ' bus.write_byte(address,block)' >> $powerbuttonscript
  195. echo ' except IOError:' >> $powerbuttonscript
  196. echo ' temp=""' >> $powerbuttonscript
  197. echo ' time.sleep(30)' >> $powerbuttonscript
  198.  
  199. echo 'try:' >> $powerbuttonscript
  200. echo ' t1 = Thread(target = shutdown_check)' >> $powerbuttonscript
  201. echo ' t2 = Thread(target = temp_check)' >> $powerbuttonscript
  202. echo ' t1.start()' >> $powerbuttonscript
  203. echo ' t2.start()' >> $powerbuttonscript
  204. echo 'except:' >> $powerbuttonscript
  205. echo ' t1.stop()' >> $powerbuttonscript
  206. echo ' t2.stop()' >> $powerbuttonscript
  207. echo ' GPIO.cleanup()' >> $powerbuttonscript
  208.  
  209. sudo chmod 755 $powerbuttonscript
  210.  
  211. argon_create_file $daemonfanservice
  212.  
  213. # Fan Daemon
  214. echo "[Unit]" >> $daemonfanservice
  215. echo "Description=Argon One Fan and Button Service" >> $daemonfanservice
  216. echo "After=multi-user.target" >> $daemonfanservice
  217. echo '[Service]' >> $daemonfanservice
  218. echo 'Type=simple' >> $daemonfanservice
  219. echo "Restart=always" >> $daemonfanservice
  220. echo "RemainAfterExit=true" >> $daemonfanservice
  221. echo "ExecStart=/usr/bin/python3 $powerbuttonscript" >> $daemonfanservice
  222. echo '[Install]' >> $daemonfanservice
  223. echo "WantedBy=multi-user.target" >> $daemonfanservice
  224.  
  225. sudo chmod 644 $daemonfanservice
  226.  
  227. argon_create_file $removescript
  228.  
  229. # Uninstall Script
  230. echo '#!/bin/bash' >> $removescript
  231. echo 'echo "-------------------------"' >> $removescript
  232. echo 'echo "Argon One Uninstall Tool"' >> $removescript
  233. echo 'echo "-------------------------"' >> $removescript
  234. echo 'echo -n "Press Y to continue:"' >> $removescript
  235. echo 'read -n 1 confirm' >> $removescript
  236. echo 'echo' >> $removescript
  237. echo 'if [ "$confirm" = "y" ]' >> $removescript
  238. echo 'then' >> $removescript
  239. echo ' confirm="Y"' >> $removescript
  240. echo 'fi' >> $removescript
  241. echo '' >> $removescript
  242. echo 'if [ "$confirm" != "Y" ]' >> $removescript
  243. echo 'then' >> $removescript
  244. echo ' echo "Cancelled"' >> $removescript
  245. echo ' exit' >> $removescript
  246. echo 'fi' >> $removescript
  247. echo 'if [ -d "/home/pi/Desktop" ]; then' >> $removescript
  248. echo ' sudo rm "/home/pi/Desktop/argonone-config.desktop"' >> $removescript
  249. echo ' sudo rm "/home/pi/Desktop/argonone-uninstall.desktop"' >> $removescript
  250. echo 'fi' >> $removescript
  251. echo 'if [ -f '$powerbuttonscript' ]; then' >> $removescript
  252. echo ' sudo systemctl stop '$daemonname'.service' >> $removescript
  253. echo ' sudo systemctl disable '$daemonname'.service' >> $removescript
  254. echo ' sudo /usr/bin/python3 '$shutdownscript' uninstall' >> $removescript
  255. echo ' sudo rm '$powerbuttonscript >> $removescript
  256. echo ' sudo rm '$shutdownscript >> $removescript
  257. echo ' sudo rm '$removescript >> $removescript
  258. echo ' echo "Removed Argon One Services."' >> $removescript
  259. echo ' echo "Cleanup will complete after restarting the device."' >> $removescript
  260. echo 'fi' >> $removescript
  261.  
  262. sudo chmod 755 $removescript
  263.  
  264. argon_create_file $configscript
  265.  
  266. # Config Script
  267. echo '#!/bin/bash' >> $configscript
  268. echo 'daemonconfigfile=/etc/'$daemonname'.conf' >> $configscript
  269. echo 'echo "--------------------------------------"' >> $configscript
  270. echo 'echo "Argon One Fan Speed Configuration Tool"' >> $configscript
  271. echo 'echo "--------------------------------------"' >> $configscript
  272. echo 'echo "WARNING: This will remove existing configuration."' >> $configscript
  273. echo 'echo -n "Press Y to continue:"' >> $configscript
  274. echo 'read -n 1 confirm' >> $configscript
  275. echo 'echo' >> $configscript
  276. echo 'if [ "$confirm" = "y" ]' >> $configscript
  277. echo 'then' >> $configscript
  278. echo ' confirm="Y"' >> $configscript
  279. echo 'fi' >> $configscript
  280. echo '' >> $configscript
  281. echo 'if [ "$confirm" != "Y" ]' >> $configscript
  282. echo 'then' >> $configscript
  283. echo ' echo "Cancelled"' >> $configscript
  284. echo ' exit' >> $configscript
  285. echo 'fi' >> $configscript
  286. echo 'echo "Thank you."' >> $configscript
  287.  
  288. echo 'get_number () {' >> $configscript
  289. echo ' read curnumber' >> $configscript
  290. echo ' re="^[0-9]+$"' >> $configscript
  291. echo ' if [ -z "$curnumber" ]' >> $configscript
  292. echo ' then' >> $configscript
  293. echo ' echo "-2"' >> $configscript
  294. echo ' return' >> $configscript
  295. echo ' elif [[ $curnumber =~ ^[+-]?[0-9]+$ ]]' >> $configscript
  296. echo ' then' >> $configscript
  297. echo ' if [ $curnumber -lt 0 ]' >> $configscript
  298. echo ' then' >> $configscript
  299. echo ' echo "-1"' >> $configscript
  300. echo ' return' >> $configscript
  301. echo ' elif [ $curnumber -gt 100 ]' >> $configscript
  302. echo ' then' >> $configscript
  303. echo ' echo "-1"' >> $configscript
  304. echo ' return' >> $configscript
  305. echo ' fi ' >> $configscript
  306. echo ' echo $curnumber' >> $configscript
  307. echo ' return' >> $configscript
  308. echo ' fi' >> $configscript
  309. echo ' echo "-1"' >> $configscript
  310. echo ' return' >> $configscript
  311. echo '}' >> $configscript
  312. echo '' >> $configscript
  313.  
  314. echo 'loopflag=1' >> $configscript
  315. echo 'while [ $loopflag -eq 1 ]' >> $configscript
  316. echo 'do' >> $configscript
  317. echo ' echo' >> $configscript
  318. echo ' echo "Select fan mode:"' >> $configscript
  319. echo ' echo " 1. Always on"' >> $configscript
  320. echo ' echo " 2. Adjust to temperatures (55C, 60C, and 65C)"' >> $configscript
  321. echo ' echo " 3. Customize behavior"' >> $configscript
  322. echo ' echo " 4. Cancel"' >> $configscript
  323. echo ' echo "NOTE: You can also edit $daemonconfigfile directly"' >> $configscript
  324. echo ' echo -n "Enter Number (1-4):"' >> $configscript
  325. echo ' newmode=$( get_number )' >> $configscript
  326. echo ' if [[ $newmode -ge 1 && $newmode -le 4 ]]' >> $configscript
  327. echo ' then' >> $configscript
  328. echo ' loopflag=0' >> $configscript
  329. echo ' fi' >> $configscript
  330. echo 'done' >> $configscript
  331.  
  332. echo 'echo' >> $configscript
  333. echo 'if [ $newmode -eq 4 ]' >> $configscript
  334. echo 'then' >> $configscript
  335. echo ' echo "Cancelled"' >> $configscript
  336. echo ' exit' >> $configscript
  337. echo 'elif [ $newmode -eq 1 ]' >> $configscript
  338. echo 'then' >> $configscript
  339. echo ' echo "#" > $daemonconfigfile' >> $configscript
  340. echo ' echo "# Argon One Fan Speed Configuration" >> $daemonconfigfile' >> $configscript
  341. echo ' echo "#" >> $daemonconfigfile' >> $configscript
  342. echo ' echo "# Min Temp=Fan Speed" >> $daemonconfigfile' >> $configscript
  343. echo ' echo 1"="100 >> $daemonconfigfile' >> $configscript
  344. echo ' sudo systemctl restart '$daemonname'.service' >> $configscript
  345. echo ' echo "Fan always on."' >> $configscript
  346. echo ' exit' >> $configscript
  347. echo 'elif [ $newmode -eq 2 ]' >> $configscript
  348. echo 'then' >> $configscript
  349. echo ' echo "Please provide fan speeds for the following temperatures:"' >> $configscript
  350. echo ' echo "#" > $daemonconfigfile' >> $configscript
  351. echo ' echo "# Argon One Fan Speed Configuration" >> $daemonconfigfile' >> $configscript
  352. echo ' echo "#" >> $daemonconfigfile' >> $configscript
  353. echo ' echo "# Min Temp=Fan Speed" >> $daemonconfigfile' >> $configscript
  354. echo ' curtemp=55' >> $configscript
  355. echo ' while [ $curtemp -lt 70 ]' >> $configscript
  356. echo ' do' >> $configscript
  357. echo ' errorfanflag=1' >> $configscript
  358. echo ' while [ $errorfanflag -eq 1 ]' >> $configscript
  359. echo ' do' >> $configscript
  360. echo ' echo -n ""$curtemp"C (0-100 only):"' >> $configscript
  361. echo ' curfan=$( get_number )' >> $configscript
  362. echo ' if [ $curfan -ge 0 ]' >> $configscript
  363. echo ' then' >> $configscript
  364. echo ' errorfanflag=0' >> $configscript
  365. echo ' fi' >> $configscript
  366. echo ' done' >> $configscript
  367. echo ' echo $curtemp"="$curfan >> $daemonconfigfile' >> $configscript
  368. echo ' curtemp=$((curtemp+5))' >> $configscript
  369. echo ' done' >> $configscript
  370.  
  371. echo ' sudo systemctl restart '$daemonname'.service' >> $configscript
  372. echo ' echo "Configuration updated."' >> $configscript
  373. echo ' exit' >> $configscript
  374. echo 'fi' >> $configscript
  375.  
  376. echo 'echo "Please provide fan speeds and temperature pairs"' >> $configscript
  377. echo 'echo' >> $configscript
  378.  
  379. echo 'loopflag=1' >> $configscript
  380. echo 'paircounter=0' >> $configscript
  381. echo 'while [ $loopflag -eq 1 ]' >> $configscript
  382. echo 'do' >> $configscript
  383. echo ' errortempflag=1' >> $configscript
  384. echo ' errorfanflag=1' >> $configscript
  385. echo ' while [ $errortempflag -eq 1 ]' >> $configscript
  386. echo ' do' >> $configscript
  387. echo ' echo -n "Provide minimum temperature (in Celsius) then [ENTER]:"' >> $configscript
  388. echo ' curtemp=$( get_number )' >> $configscript
  389. echo ' if [ $curtemp -ge 0 ]' >> $configscript
  390. echo ' then' >> $configscript
  391. echo ' errortempflag=0' >> $configscript
  392. echo ' elif [ $curtemp -eq -2 ]' >> $configscript
  393. echo ' then' >> $configscript
  394. echo ' errortempflag=0' >> $configscript
  395. echo ' errorfanflag=0' >> $configscript
  396. echo ' loopflag=0' >> $configscript
  397. echo ' fi' >> $configscript
  398. echo ' done' >> $configscript
  399. echo ' while [ $errorfanflag -eq 1 ]' >> $configscript
  400. echo ' do' >> $configscript
  401. echo ' echo -n "Provide fan speed for "$curtemp"C (0-100) then [ENTER]:"' >> $configscript
  402. echo ' curfan=$( get_number )' >> $configscript
  403. echo ' if [ $curfan -ge 0 ]' >> $configscript
  404. echo ' then' >> $configscript
  405. echo ' errorfanflag=0' >> $configscript
  406. echo ' elif [ $curfan -eq -2 ]' >> $configscript
  407. echo ' then' >> $configscript
  408. echo ' errortempflag=0' >> $configscript
  409. echo ' errorfanflag=0' >> $configscript
  410. echo ' loopflag=0' >> $configscript
  411. echo ' fi' >> $configscript
  412. echo ' done' >> $configscript
  413. echo ' if [ $loopflag -eq 1 ]' >> $configscript
  414. echo ' then' >> $configscript
  415. echo ' if [ $paircounter -eq 0 ]' >> $configscript
  416. echo ' then' >> $configscript
  417. echo ' echo "#" > $daemonconfigfile' >> $configscript
  418. echo ' echo "# Argon One Fan Speed Configuration" >> $daemonconfigfile' >> $configscript
  419. echo ' echo "#" >> $daemonconfigfile' >> $configscript
  420. echo ' echo "# Min Temp=Fan Speed" >> $daemonconfigfile' >> $configscript
  421. echo ' fi' >> $configscript
  422. echo ' echo $curtemp"="$curfan >> $daemonconfigfile' >> $configscript
  423. echo ' ' >> $configscript
  424. echo ' paircounter=$((paircounter+1))' >> $configscript
  425. echo ' ' >> $configscript
  426. echo ' echo "* Fan speed will be set to "$curfan" once temperature reaches "$curtemp" C"' >> $configscript
  427. echo ' echo' >> $configscript
  428. echo ' fi' >> $configscript
  429. echo 'done' >> $configscript
  430. echo '' >> $configscript
  431. echo 'echo' >> $configscript
  432. echo 'if [ $paircounter -gt 0 ]' >> $configscript
  433. echo 'then' >> $configscript
  434. echo ' echo "Thank you! We saved "$paircounter" pairs."' >> $configscript
  435. echo ' sudo systemctl restart '$daemonname'.service' >> $configscript
  436. echo ' echo "Changes should take effect now."' >> $configscript
  437. echo 'else' >> $configscript
  438. echo ' echo "Cancelled, no data saved."' >> $configscript
  439. echo 'fi' >> $configscript
  440.  
  441. sudo chmod 755 $configscript
  442.  
  443.  
  444. sudo systemctl daemon-reload
  445. sudo systemctl enable $daemonname.service
  446.  
  447. sudo systemctl start $daemonname.service
  448.  
  449. if [ -d "/home/pi/Desktop" ]; then
  450. sudo wget http://download.argon40.com/ar1config.png -O /usr/share/pixmaps/ar1config.png
  451. sudo wget http://download.argon40.com/ar1uninstall.png -O /usr/share/pixmaps/ar1uninstall.png
  452. # Create Shortcuts
  453. shortcutfile="/home/pi/Desktop/argonone-config.desktop"
  454. echo "[Desktop Entry]" > $shortcutfile
  455. echo "Name=Argon One Configuration" >> $shortcutfile
  456. echo "Comment=Argon One Configuration" >> $shortcutfile
  457. echo "Icon=/usr/share/pixmaps/ar1config.png" >> $shortcutfile
  458. echo 'Exec=lxterminal -t "Argon One Configuration" --working-directory=/home/pi/ -e '$configscript >> $shortcutfile
  459. echo "Type=Application" >> $shortcutfile
  460. echo "Encoding=UTF-8" >> $shortcutfile
  461. echo "Terminal=false" >> $shortcutfile
  462. echo "Categories=None;" >> $shortcutfile
  463. chmod 755 $shortcutfile
  464.  
  465. shortcutfile="/home/pi/Desktop/argonone-uninstall.desktop"
  466. echo "[Desktop Entry]" > $shortcutfile
  467. echo "Name=Argon One Uninstall" >> $shortcutfile
  468. echo "Comment=Argon One Uninstall" >> $shortcutfile
  469. echo "Icon=/usr/share/pixmaps/ar1uninstall.png" >> $shortcutfile
  470. echo 'Exec=lxterminal -t "Argon One Uninstall" --working-directory=/home/pi/ -e '$removescript >> $shortcutfile
  471. echo "Type=Application" >> $shortcutfile
  472. echo "Encoding=UTF-8" >> $shortcutfile
  473. echo "Terminal=false" >> $shortcutfile
  474. echo "Categories=None;" >> $shortcutfile
  475. chmod 755 $shortcutfile
  476. fi
  477.  
  478.  
  479. echo "***************************"
  480. echo "Argon One Setup Completed."
  481. echo "***************************"
  482. echo
  483. if [ -d "/home/pi/Desktop" ]; then
  484. echo Shortcuts created in your desktop.
  485. else
  486. echo Use 'argonone-config' to configure fan
  487. echo Use 'argonone-uninstall' to uninstall
  488. fi
  489. echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement