How can I ensure that binaries installed by my install script are executable?
How can I ensure that binaries installed by my install script are executable?
I've just created my first github repository: https://github.com/WinEunuuchs2Unix/eyesome
I've uploaded all the files but have concerns with how the end-user will copy them after download.
Here is the copy-files
script (abridged) they would run:
copy-files
!/bin/sh
if [ $(id -u) != 0 ]; then # root powers needed to call this script
echo >&2 $0 must be called with sudo powers
exit 1
fi
cp -v ./eyesome.sh /usr/local/bin/
cp -v ./eyesome-cfg.sh /usr/local/bin/
cp -v ./eyesome-src.sh /usr/local/bin/
cp -v ./eyesome-sun.sh /usr/local/bin/
cp -v ./wake-eyesome.sh /usr/local/bin/
cp -v ./start-eyesome /etc/cron.d/
cp -v ./daily-eyesome-sun /etc/cron.daily/
cp -v ./systemd-wake-eyesome /lib/systemd/system-sleep/
exit 0
My first thought is after someone downloads the files none are marked as executable?
The copy-files
script has a section for "uninstalling" that is inactive. Is this a common courtesy to provide?
copy-files
Comments on further reading to improve my github
and refine my copy-files
code are also appreciated.
github
copy-files
2 Answers
2
You say: "My first thought is after someone downloads the files none are marked as executable?" git
allows you to mark the files executable and preserve permissions. Before doing git commit -a -m 'Some changes';git push
just run chmod +x
on the files.
git
git commit -a -m 'Some changes';git push
chmod +x
Currently all your files are in top level of directory. This looks kinda messy and disorganized. It's best to have directories and organize things. If you look at professional organizations, they have doc/
, scr/
directories, or at least project's top level module name directory with submodules inside.
doc/
scr/
When user downloads zip file and extracts everything, what will they see ? Tons of files scatered all over the directory where they extracted it. So having directories in your project helps to minimize the clutter.
Some repositories I have do follow same thing - everything is in top level. But I don't change that because I already have instructions written in my Ask Ubuntu answers, so going back and trying to figure out what answers to change is too problematic.
Have an installation script. Instead of writing too many instructions to the user, this one thing can save time for them and you.
Figure out how to use develop
and master
branches. You can keep a working version in master
and work on changes in develop
. That way users have working code, and you're not freaking out about code being broken and users unhappy.
develop
master
master
develop
Your README.md
is bare. Add some useful information. Particularly, outline things that are necessary as dependencies for the project, specifically commands not installed on default Ubuntu system ( which is what your projects generally tend to aim at).
README.md
Lots to digest. Can you provide a link to a sample "installation script"? I haven't created any doc yet. That will take a week with .GIF's, etc.
– WinEunuuchs2Unix
Sep 16 '18 at 20:27
@WinEunuuchs2Unix Not really, at least not anything good. I've an install script for lks-indicator which I used to use before I figured out debian packaging is a bit more suitable for my needs. I'd probably do things a lot differently now than back then. The
install
command suggested in Chris's answer should be one of the things in the script itself. Permissions, checking if certain commands are installed, etc. - all that can be done in install scripts– Sergiy Kolodyazhnyy
Sep 16 '18 at 20:35
install
I've just uploaded new version of
copy-files
to github using Chris's suggestion. I thought creating a .deb
would be a lot of work? Especially since there are no program dependencies on libraries and what not. Thanks for pointing out not to use your lks-indicator install script and opt for something more robust.– WinEunuuchs2Unix
Sep 16 '18 at 20:38
copy-files
.deb
@WinEunuuchs2Unix It depends. For shell scripts - making a
.deb
is some work, but if you do things right you can make one in less than an hour. For Python, there's ways to automate it.– Sergiy Kolodyazhnyy
Sep 16 '18 at 20:51
.deb
Thanks. I'll look around for a GUI or CLI script to automate the process of creating a .deb script for < 10 files to 4 directories.
– WinEunuuchs2Unix
Sep 16 '18 at 20:58
Instead of using cp
, take a look at install
, e.g.
cp
install
install ./eyesome.sh /usr/local/bin/
By default, it will use mode 755, but you can override that with the -m
option if you need something different.
-m
The next logical step would probably be to build a proper package for the operating system(s) you're targeting.
I should have mentioned installing to Ubuntu / Debian. Programs are all in bash. Bash Arrays are used so version must be >= 4 I think. Version 4 is almost a decade old so I didn't test for it.
– WinEunuuchs2Unix
Sep 16 '18 at 20:16
@WinEunuuchs2Unix, what does any of that have to do with my recommendation? Ubuntu ships with the
install
command.– Chris
Sep 16 '18 at 20:18
install
I was responding to your answer part: "The next logical step would probably be to build a proper package for the operating system(s) you're targeting."
– WinEunuuchs2Unix
Sep 16 '18 at 20:22
I've implemented your
install
technique and I think it works like a charm. I've also changed the script name from copy-files
to install.sh
and added extra features: github.com/WinEunuuchs2Unix/eyesome/blob/master/install.sh Thanks for your help :)– WinEunuuchs2Unix
Sep 18 '18 at 0:40
install
copy-files
install.sh
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
Generally speaking, this kind of question is off-topic here. It's primarily opinion-based and too broad, and also may require us to go off-site to fully understand it. But I'll interpret it this way: "How can I ensure that binaries installed by my install script become executable?" In the future, please try to stay on-topic as defined in the help center.
– Chris
Sep 16 '18 at 20:10