💾 Archived View for alaskalinuxuser.ddns.net › 2023-12-05.gmi captured on 2024-09-29 at 00:22:34. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
">
49w, https://alaskalinuxuser3.ddns.net/wp-content/uploads/2023/12/
updateclickable-300x212.png 300w" sizes="(max-width: 749px) 100vw, 749px" /
I would like to start this post by saying I’m not that bright. Further, there
are way, way, way brighter people, of whom you should be following their blog.
However, for what it is worth, this is my script for automagically updating my
clickable app for Ubuntu Touch. You can take it and use it however you see fit.
In particular, the jq arguments for json editing on the fly with variables
might be useful to others.
updating folder.\nrm -rf ./updating\n\n# Create and enter the updating
folder.\nmkdir updating\ncd ./updating\n\n# Use wget to procure the updated zip
file.\nwget http://thebookwurm.com/the_book.zip\n\n# Unzip the zip file.\nunzip
./the_book.zip \n\n# Remove the zip file.\nrm the_book.zip \n\n# Clone the
repository.\ngit clone https://gitlab.com/alaskalinuxuser/
app_ubport_thebookwurm.git\n\n# Enter the repository.\ncd
app_ubport_thebookwurm/www\n\n# Move the new readme and htm file.\nmv ../../
readme.txt ./\nmv ../../go_book.htm ./\n\n# Remove the web folder for the
book.\nrm -rf the_book\n\n# Copy the new web folder for the book.\ncp -Rav
../../the_book ./\n\n# Go up one directory.\ncd ..\n\n# Export today's
date.\nexport today="$(date '+%Y%m%d')"\necho $today\n\n# Use today's date
and update the version number with jq.\njq --arg today $today '.version |=
$today' ./manifest.json |tee ./temp.json\ncat temp.json \nmv temp.json ./
manifest.json\nrm ./temp.json\n\n# Run clickable to build the latest
version.\nclickable\n\n# Move the built updated file to the Downloads
directory.\ncp ./build/all/app/*.click ~/Downloads/\n\n# Update the repository
automatically-ish\ngit status\ngit add .\ngit commit -m "Updated " -
m "$today"\n# You will be prompted for the password.\ngit push\n\n# Go to the
downloads folder.\ncd ~/Downloads/\n \n# Remove any updating folder.\nrm -rf ./
updating\n\n# And gracefully exit.\nexit 0
Jq, by default just outputs the modified json text to the stdout, so it doesn’t
actually edit the file itself. You could use stdin with cat or something, but I
like using tee to display the output and put it into a file that I then move
over the original, but that’s just me.
This allows me to *just about* completely automate the building and updating
process for a web app that I maintain on Ubuntu Touch. I would like to note
that the website maintainer updates the content of the website that my web app
captures, and I use this by permission for folks on Ubuntu Touch who want the
Bible and resources available in a web app form without having to burn data to
access them.
So far, this works pretty well. The date variable stored as $today is useful
for the version number since I put it in a YYYYMMDD format, always ensuring
that it increments upwards over time. This is also useful for the commit
message which will read “Updated ” and if on Gitlab/hub, you press the three
dots (…) to see the date.
It is not completely automated, since I have to type my password and username,
however, if you use ssh keys, you could completely automated this, or you can
pass your login credentials via plain text (which is a really bad idea) with:
git push https://username:password@myrepository --all
But I don’t prefer to do that. I would also note that it will store username
and password in plaintext in the git configuration, supposedly, which is also
another good reason not to do that.
Linux – keep it simple.