WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Y/N script  (Read 2822 times)

Offline rexi

  • Newbie
  • *
  • Posts: 37
Re: Y/N script
« Reply #15 on: December 19, 2023, 07:10:48 AM »
So after a few days of procrastination, I got back into development. I took my script and edited the .desktop file, then packaged everything, generated the md5sum and put it in the cde folder.
But after turning on the computer, the application does not appear anywhere and cannot be started in any way.
I keep mulling over the tce.installed folder, but I don't know if that's it and I don't know what to put in there either (I'm not that experienced with linux).

Here is the content of the .desktop file.
Code: [Select]
[Desktop Entry]
Name=Exit
Exec=cliorx sudo exit.sh
Icon=exittc
X-FullPathIcon=/usr/local/share/pixmaps/exittc.png
Type=Application
Categories=System;

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11282
Re: Y/N script
« Reply #16 on: December 19, 2023, 07:41:16 AM »
Hi rexi
The difference between a  cde  and  tce  folder is  cde
is used for  read-only  media like CD and DVD. When
using writable media (disk, USB thumb drive, SD card, etc.)
you should alway use a  tce  folder.

Offline rexi

  • Newbie
  • *
  • Posts: 37
Re: Y/N script
« Reply #17 on: December 19, 2023, 08:34:43 AM »
1. Thank you for the useful information.
2. I would use the TCE folder, but I use tinycore on a USB flash drive (created with rufus (https://rufus.ie/en/) and I used the .iso from the official site) and the TCE folder is not there.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11282
Re: Y/N script
« Reply #18 on: December 19, 2023, 12:12:33 PM »
Hi rexi
Third party installers don't know how to handle Tinycore.

Boot your flash drive.
If you used the Coreplus ISO, tc-install-GUI.tcz should be present.
Otherwise, install tc-install-GUI.tcz.
Use tc-install-GUI.tcz to install Tinycore to another flash drive.

Offline rexi

  • Newbie
  • *
  • Posts: 37
Re: Y/N script
« Reply #19 on: December 20, 2023, 07:47:45 AM »
I've known about tc-install-GUI.tcz for a long time, but I've never seen a reason to use it (plus I find it a bit more complicated to install)
Is there any way to burn an .iso to a flash drive on TinyCore?

Offline CentralWare

  • Administrator
  • Hero Member
  • *****
  • Posts: 1654
Re: Y/N script
« Reply #20 on: December 20, 2023, 11:26:48 PM »
For most bootable ISO files, you can use "dd"

Code: [Select]
dd if=filename.iso of=/dev/usbstick bs=1M status=progresswhere "usbstick" is your USB device's designation.

WARNING: ALL information on /dev/usbstick will be wiped out without notice or hesitation - check your typing BEFORE pressing ENTER!

If you're using a Windows based machine to set things up with, download the program "Rufus" which can burn your ISO to USB with some sane logic involved.
« Last Edit: December 20, 2023, 11:28:22 PM by CentralWare »
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline rexi

  • Newbie
  • *
  • Posts: 37
Re: Y/N script
« Reply #21 on: December 21, 2023, 06:29:51 AM »
OK, fine, but could we go back to my original question. What do I put in the tce.install folder to make the app work?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11282
Re: Y/N script
« Reply #22 on: December 21, 2023, 07:44:09 AM »
Hi rexi
... then packaged everything, generated the md5sum and put it in the cde folder.
But after turning on the computer, the application does not appear anywhere and cannot be started in any way. ...
I guess I missed the part that mentions how you are loading
your new extension.

If you want it to load automatically when you boot, add it to
your  onboot.lst  file.

Or, if you want to load it from the command line:
Code: [Select]
tce-load -i YourExtensionName.tcz
You might also want to take an hour to read this fine book:
http://tinycorelinux.net/book.html

Offline CentralWare

  • Administrator
  • Hero Member
  • *****
  • Posts: 1654
Re: Y/N script
« Reply #23 on: December 21, 2023, 08:24:14 AM »
@rexi: I had to read the entire thread in order to follow along and answer your last question; which I think I now know what you're after.

Copy/paste the following into a file called /opt/test.sh; run this script and it will create the files used in this example.
Code: [Select]
#!/bin/sh

## If our graphic isn't already downloaded, do so here ##
[ ! -f /usr/local/share/pixmaps/exit.png ] && wget -O /usr/local/share/pixmaps/exit.png https://pngimg.com/uploads/exit/exit_PNG35.png

## Create our "power button" icon on the desktop ##
cat > /usr/local/share/applications/exit.desktop << EOF
[Desktop Entry]
Name=exit
Exec=cliorx sudo sh /opt/yesno
Icon=exit
Terminal=false
X-FullPathIcon=/usr/local/share/pixmaps/exit.png
Type=Application
Categories=Utility;
EOF

## Create our Y/N script with shut-down ##
cat > /opt/yesno << EOF
#!/bin/sh

echo -n "Do you want to turn off your computer? (y/N) "
read yesno
case \$yesno in
   [Yy]*) sudo poweroff ;;
esac
EOF
sudo chmod +x /opt/yesno && chown tc.staff /opt/yesno

In the above example, your extension ("yesno.tcz") would consist of:
/usr/local/share/pixmaps/exit.png (our desktop graphic)
/usr/local/share/applications/exit.desktop (our desktop info file)
/opt/yesno (our "program")
/usr/local/tce.installed/yesno (without .sh in the filename) which is launched as the extension is brought online.  If you do not need to do anything right when the extension is brought online, you do not need to create it - an empty one will be created by tce-load

Once you have your yesno.tcz and its associated files (.tcz.dep, .tcz.info, etc.) placed in the /etc/sysconfig/tcedir/optional directory, add yesno.tcz to /etc/sysconfig/tcedir/onboot.lst and it will launch every time you boot the computer.

NOTE: If using the ISO, you will do this in the /mnt/sda1/cde directory instead of /mnt/sda1/tce directory
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline rexi

  • Newbie
  • *
  • Posts: 37
Re: Y/N script
« Reply #24 on: December 21, 2023, 09:10:58 AM »
@rich I forgot to add apps to onboot.lst, everything works fine now, thanks.

@CentralWare I already created the application manually, but thank you for trying to help.