Categories
Technology Tutorial Ubuntu

Advanced PDF Printing on Ubuntu

I travelled down a road that failed, but I learned some cool things about printing to PDF on Ubuntu that I think are worth logging and sharing for others.

1. Out-of-the-Box PDF Printing (in case you didn’t know)

In case you are new to ubuntu and didn’t know it, basic PDF printing is already installed and working perfectly. All you do is choose ‘print to file’ when you select your printer and PDFs are created. This might be all you need to know from this tutorial.

2. Converting with Ghostscript / ‘convert’ Command

This convert command is powerful. You can convert pretty much whatever image file to PDF. Probably you can convert other files, too. If you don’t believe me how powerful it is, just type man convert and check out the options…

A problem, however, is that it had a significant security issue in the past and so all rights to use the command are disabled by default. If you are running a server probably you should do your own research on the topic but if you are regular user like me you can probably follow the advice I found online to just remove the security policy file / rename it. Here is what I did and it removed all the permission errors I got while trying to run the command:

Move to the directory where the policy is: cd /etc/ImageMagick-6
Move the ‘policy.xml’ file while giving it the a new name (which ultimately just renames it): sudo mv policy.xml policy_disabled.xml

Now you can run the ‘convert’ command and send whatever it is to a pdf:

convert original_image_file.jpg output_pdf_file.pdf

3. Installing a ‘Virtual Printer’ and ‘Printing’ to it graphically

Install the thing: sudo apt install printer-driver-cups-pdf

As soon as it’s done you should be notified that a new ‘printer’ has been installed, just like it was a normal hardware printer. Now you can simply ‘print’ like you normally would to the printer called “PDF”. It will output the files to your home directory in the “PDF” folder.

4. Advanced printing with the command line using the Virtual Printer

Now that you have installed the printer-driver-cups-pdf virtual printer thing above, you now have a ‘fake printer’ in your computer and can now do ‘lpr printing’ in the commmand line. You can learn about what you can do with lpr here but instead what we’re going to do is simply direct the printing to the printer called “PDF”.

So whatever you can do with a regular printer, it seems you can do it now to PDF.

5. Other

There is also this thing which may be of value researching. I didn’t have time but it seems like there may be other value there ps2pdfwr. This is already installed with ubuntu. It takes postscript stuff and makes PDFs. You can type man ps2pdfwr in your terminal to learn more.

Hope this helps.

Categories
Freedom and Privacy Tutorial Ubuntu Touch

How to set up Gitlab with Ubuntu Touch 2FA Manager App

I had been using Ubuntu Touch Authenticator app, but I wanted to try out the 2FA Manager app to see how that worked for me. The only problem was that I had never reset my 2FA stuff that I originally set up so this was my first time switching devices. It was easy, but it was also not documented. I hope this simple guide helps and perhaps the steps of this process also apply to other 2FA sites:

In your Gitlab account

  1. Log into your gitlab account
  2. Go to “Settings” under your top right avatar
  3. Go to “Account”
  4. Click the ‘Manage Two Factor Authentication” button
  5. Click the ‘Disable two-factor authentication’ button which will then warn give you this warning “Are you sure? This will invalidate your registered applications and U2F devices.”
  6. Select ‘Ok’ on warning screen

This will now present you with a screen and QR code where you will scan it and bring it into the Ubuntu Touch 2FA Manager app. So now let’s move to your ubuntu touch device…

On your Ubuntu Touch device

  1. Download / install tagger app if you have not already done so
  2. Download install the 2FA Manager app if you have not already done so
  3. Open the 2FA Manager App
  4. Open Tagger app and point camera at QR code and patiently wait… adjust camera position if needed until it registers the QR code. You will know this is working when the dialogue with “open url, copy to clip, generate qr code” buttons pops up
  5. Select ‘open URL’
  6. Add a description. This is just a friendly name that will help you remember what this key is for as you may build up many keys over the years.
  7. Press ‘Add’ button. You should now be taken to the 2FA Manager app to a screen with a 6 digit bold code and a purple progress meter that is moving. You will notice that each time the progress meter reaches the end, it will loop back with a new 6 digit number. You will also notice that if you tap this 6 digit code it will open it up and make it much bigger and easier to read and also give you the ability to copy this code to clipboard. Whichever way you prefer, these are the two ways you can obtain your 2FA codes and these codes are what you will use to log into Gitlab each time, and also to use to finish up your setup in your Gitlab account.
  8. Go back to Gitlab

Meanwhile, back at Gitlab…

  1. Look at your 2FA Manager app and grab the 6 digit code presented on the screen. But hurry! (dramatic music here) If you don’t grab it quick enough the next one will be generated. This is for security if you were wondering and limits the chance of someone stealing your stuff…
  2. Enter the 6 digit code into the ‘pin code’ field on your Gitlab 2FA setup page you should still be on
  3. Select ‘Register with two-factor app’ button
  4. Save your recovery codes: If all goes well you should now be presented with a ‘congratulations’ screen and a list of 10 random looking letters and number strings with bullet points. These are your recovery keys so save them somewhere safe. I recommend the keypassxc app as it’s a really great password manager for your laptop / desktop ubuntu environment.
  5. After you have these recovery codes safely stored, press ‘proceed’. If you got an ‘invalid code’ message, it probably means you weren’t fast enough with steps 1-3 above so repeat but faster 😉

You should now be brought back to your gitlab Account page and good to go. You can probably use this workflow above to do 2FA setups in other systems as well.

Categories
Business PrestaShop Technology Tutorial Ubuntu

Setting Up Prestashop on Digital Ocean Ubuntu Server

The background to this post is that I had a sudden need to ‘figure out shopping carts’. I understood from times past it probably isn’t wise to have a shopping cart that intends to scale on a shared cpanel host, even though it’s pretty dead easy to set that up. I decided this was the day I had to learn how to set up an Ubuntu server myself and face it until I knew enough to do so.

I started with Digital Ocean because I recall testing a ‘droplet’ and being surprised how easy and nice it was. They also support UBports and their servers so I appreciate that. I got a promotional code to try it out and glad I did. I think it’s a really nice solution.

The real purpose of this tutorial is to make sure I don’t forget all the things I learned and also to leave some bread crumbs for others who might want to do the same thing.

I landed on prestashop because it’s very open software, very flexible, been around for many years, and has a bunch of modules that should be quite helpful to roll out store after store.

The idea of this server is that it will run the ‘main business website’ as well as the shopping cart.

Any time you see ‘123.123.123.123’ this is your IP address for your server. Replace it with your actual one, of course.

You should also have a nice password manager set up to save yourself much time and pain as you learn. I recommend keepasxc

Let’s get started

Big Step 1 – Set up the Digital Ocean Droplet

  1. Initiate your server / droplet
    I won’t give detailed instructions here because there is lots of documentation out there. One thing I will say is that i used an Ubuntu 18.04 LTS server with 2GB of ram to make sure I had enough ram to do what’s needed for both the main site and prestashop.
  2. Immediately set up your A records to point to your domain.
    In Digital Ocean (“DO”) it’s pretty easy but I don’t have any links to it. Just go to ‘networking’, add your domain, then create your domains, subdomains, etc, and then point the A record to the Server you just initialed in step 1 above. This step is important to do right away because propagation of the name server to the IP address / box takes an hour or more sometimes depending on where you are.
  3. Set up your SSH keys
    Before you install the droplet, make sure your SSH keys are set up properly because you are going to use them a lot in the terminal. Here is some ssh tutorial. Note that it’s a little hard for me to find SSH stuff in the DO backend so for the records it’s at settings / security and then a tab (I think…)
  4. SSH into your new server
    ssh root@123.123.123.123
  5. Set up a non-root user account on the server
    This is a nice detailed tutorial on this if you’d like here.

Otherwise, this summaries it:

  • Log into the server as root: ssh root@123.123.123.123
  • Make sysadmin user: adduser sysadmin and follow the prompts (should be password prompt and then a few questions)
  • Add new user to the sudo list: sudo usermod -aG sudo sysadmin
  • Switch to new sysadmin user: su sysadmin
  • (Optional) Test the new-found powers by running this and then cancelling: sudo dpkg-reconfigure tzdata

Helpful note
If you find you are not getting prompted for the questions after running the adduser command, it might be because you accidentally ran useradd command like me… weird how it works both ways…

  1. Update the server’s packages
    sudo apt update
    sudo apt upgrade

Big Step 2 – Install Apache

  1. sudo apt install apache2
  2. Check to see if this triggered new packages to upgrade: sudo apt update
  3. If packages need updating: sudo apt ugrade

Big Step 3 – Install PHP

There were about a million different tutorials out there that worked but were pretty hard. At the end of all that I found this which seems to work just fine and dandy, so hopefully it works for you:

  1. Add PPA: sudo add-apt-repository ppa:ondrej/php
  2. Update packages: sudo apt update
  3. Install php (adjusting version and number as you over time and making sure the version is correct for Prestashop / other software): sudo apt install php7.3
  4. Test php version: `php -v’
  5. Add the modules required for Prestashop (adjust for whatever else you are installing): sudo apt install libapache2-mod-php7.3 php7.3 php7.3-common php7.3-curl php7.3-gd php7.3-imagick php7.3-mbstring php7.3-mysql php7.0-json php7.3-xsl php7.3-intl php7.3-zip
  6. Open this file (adjust PHP version as needed / as appropriate): sudo nano /etc/php/7.3/apache2/php.ini
  7. Add these lines of code. Truthfully I don’t know where you are supposed to add them so I added them near the bottom in the first space from the bottom I could find, but not at the very bottom. Adjust as needed:
file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago
  1. Restart apache2 after doing php changes (now) with this sudo systemctl restart apache2.service (I’m not 100% sure this step is required, but never hurts!)
  2. Test that PHP is working by:
  • Creating this test file: sudo nano /var/www/html/phpinfo.php
  • Adding this info to the file and saving: <?php phpinfo( ); ?>
  • Going to the URL where this file is where you should see a boring PHP info page: 123.123.123.123/phpinfo.php
  • Deleting the file if the test is good: sudo rm /var/www/html/phpinfo.php

Big Step 4 – Install Mariadb

Apparently mariadb is like mysql but getting more love as we move into the future. I’m just following along.

  1. Create a database name and save it to your password manager. I’m going to use ‘presta_db’ for this. You can call it what you’d like.
  2. Create a database user name and a password and do the same in the password manager.
  3. Install mariadb: sudo apt-get install mariadb-server mariadb-client
  4. Do a security upgrade on it and make a password, etc for database: sudo mysql_secure_installation. Follow the prompts with very likely these answers: Enter, Y, password, repeat password, Y, Y, Y, Y

Big Step 5 – Create your Database in Mariadb

Assuming you did the steps above in step 4, you should now be able to log into your database area with your new password you created. I don’t know if you HAVE to use CAPS for the maria commands, but I do just for visual aid, which is probably why we see this around town…

  1. Log into mariadb: sudo mysql -u root -p
  2. Create your database with the database name you saved to your password manager above: CREATE DATABASE presta_db;
  3. Create the user and password for the database replacing username and password in the following code with yours between the apostrophes: CREATE USER 'username_here'@'localhost' IDENTIFIED BY 'new_password_here';
  4. Do whatever this does, lol: GRANT ALL ON presta_db.* TO 'username_here'@'localhost' IDENTIFIED BY 'same_password_here' WITH GRANT OPTION;
  5. Flush stuff: FLUSH PRIVILEGES;
  6. Exit stuff: EXIT;

Big Step 6 – Create the Directory Structure for a Shared Server Environment (Optional)

First a good resource for hosting multiple domains on a single ubuntu server.

I will provide the directory structure I used for both the ‘standalone’ setup and the ‘shared’ setup (multiple domains on one machine). You can choose and adjust how you like.

  1. Make the full path to the place where you plan to put Prestashop on a shared server environment:
  • sudo mkdir -p /var/www/shop.domain.com/public_html
  • repeat this command for each domain, changing the shop.domain.com/ part to whatever is appropriate

On a standalone environment: sudo mkdir -p /var/www/html/domain.com

Bit Step 7 – Set up your Virtual Host Files in Apache for Each Domain (Shared server environment)

This blog really says it all resource, except, you don’t have to mess around with that /etc/hosts stuff that he talks about at the end. I did that and messed things up on DO environment… The key with this section here is to make sure (in whatever way you are most confortable) that you have a ‘domain.com.conf’ file sitting in the /etc/apache2/sites-available/ directory with the correct domain information in that file and saved. If you don’t, you’ll have pain. The nice part is this wasn’t as scary as I first thought it was. The key items you’ll need are probably these for a basic setup, and this worked fine for Prestashop for me:

ServerName domain.com
ServerAlias www.domain.com
ServerAdmin yourname@youremail.com
DocumentRoot /var/www/domain.com/public_html/prestashop

Lets Encrypt (awesome free SSL cert system) will do ‘the rest’ for you in an upcoming step to deal with port 443 / https:// if you were wondering…

Here is a summary of what I do showing two domains on a shared environment getting their own conf files which we can then edit:

Copy default template for domain 1: sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/shop.domain1.com.conf

Copy default template for domain 2: sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/domain2.com.conf

sudo nano edit each of the above configs with:

  1. Uncomment ServerName line and add correct one:
  2. Add ServerAlias for the www entry below it (not showing in default for some reason, so type it in ServerAlias www.domain.com )
  3. Update admin email
  4. Update document root to /var/www/shop.dailynow.ca/public_html
  5. Repeat for conf files for any other domains on server
  6. Reload Apache just because: systemctl reload apache2.service
  7. Disable the default conf file: sudo a2dissite 000-default.conf
  8. Enable domain 1: sudo a2ensite shop.domain1.com.conf
  9. Enable domain 2 (if applicable): sudo a2ensite domain2.com.conf
  10. Enable re-write mode (which drops some code into your conf file above): sudo a2enmod rewrite
  11. Restart Apache again for fun: sudo systemctl restart apache2.service

Big Step 8 – Putting Prestashop on the server

  1. Install the unzip tool for dealing with the Prestashop zip file: sudo apt install unzip
  2. Navigate to a safe place for doing stuff: cd /tmp/
  3. Verify that you are updating the link in the following code to the latest version. You can verify by going to thei releases page, clicking the latest, right clicking on the zip file and selecting copy link location and pasting into url in code here:
  4. Download the goods! wget -c https://github.com/PrestaShop/PrestaShop/releases/download/1.7.6.7/prestashop_1.7.6.7.zip
  5. Create a prestashop empty directory and unzip the file you just downloaded in step 4 into it: unzip prestashop_1.7.6.7.zip -d prestashop/
  6. move up a level to be able to perform next ‘move’ cd ..
  7. Move the whole directory you just made to the appropriate directory you created in ‘Big Step 6″ above. Adjust as required to your situation: sudo mv prestashop /var/www/shop.domain.com/public_html/
  8. Assign the correct ownership to the prestashop directory (adjust path as fitting for your situation): sudo chown -R www-data:www-data /var/www/shop.domain.com/public_html/prestashop/
  9. Assign the correct permissions to the same directory: sudo chmod -R 755 /var/www/shop.domain.com/public_html/prestashop/

Big Step 9 – Lets Encrypt

I feel, although I’m not sure, that this is the right place for this section: after everything is setup and just before installing Prestashop. When you start the Prestashop installation process it passes sensitive data around like passwords so I feel it should be set up here. However, I’m going to write a warning here, and then repeat it later: you must enable SSL in Prestashop itself in the admin area or things are going to go really bad. SUPER Special thanks to whoever you are author of this blog.

At this point, too, you’ll need to make sure that your domain has propagated (which is why I put the nameserver stuff at the very top). If it hasn’t propagated, Letsencrypt will fail it’s process on the last part. Here is how you can check to make sure you’re ready to continue:

  1. From inside your server, check your current ip address with ifconfig
  2. In a new terminal window (not the server itself but your own PC in a different network) ping your domains individually: ping domain1.com ping domain2.com
  3. Make sure the bounce ip address from ping matches the ifconfig ip address of your server / droplet in step 1 above.

If you get a long hang or failed ping, probably your domain hasn’t propagated yet. You’ll have to wait as I don’t know of another way to speed things up, except I believe you can reduce the TTL rate from 3600 down but that may have adverse affects on your server resources. Study this topic yourself if you run into it.

Bonus Tip
You can find out a bunch of cool stuff about your domains and propagation with DIG command dig domainname.com .
This command seems to be more powerful than propagation and can at least tell you if things ‘should’ propagate correctly before it actually propagates.
Here are two cool ones:

  • Find out the name server associated with your domain: dig domain.com NS
  • Check out that an A record is setup and working: dig domain.com A

Install LetsEncrypt

  1. Add the PPA: sudo add-apt-repository ppa:certbot/certbot
  2. Install the certbot: sudo apt install python-certbot-apache
  3. Test the syntax of, what I believe, are the conf files and apache conf files: sudo apache2ctl configtest. If you get an ‘OK’ message, continue. If you change anything in your conf files, don’t forget to reload Apache after sudo systemctl reload apache2
  4. Enable the firewall: sudo ufw enable
  5. MISSION CRITICAL Right here and right now, be sure you allow the ssh rule in the firewall rules, otherwise, you’ll get locked out of your server like I did. Thankfully with DO if you do get locked out you can go in through their virtual console, but still…So, simply run this line of code to open up SSH in the firewall: sudo ufw allow ssh
  6. Let https traffic through so that Letsencrypt can do its thing: sudo ufw allow 'Apache Full'
  7. Check the firewall status which should show active, as well as show BOTH 22/tcp and Apache Full enabled for both ipv4 and ipv6. Don’t continue until these are both present: sudo ufw status
  8. RUN IT sudo certbot --apache -d your_domain -d www.your_domain
  9. Most questions are easy to answer. Choose option 2 for normal and higher security forcing redirects to https. Note! It seems after you choose this it’s forever impossible to connect with regular http:// on port 80. This may be important? Not sure…didn’t affect prestashop.
  10. Probably you should test your domains here to make sure https:// is working. I didn’t write any steps for this as I figured Prestashop will be a good test coming soon…
  11. Repeat steps 8-10 for other domains (ie. domain2.com) if required adjusting as appropriate
  12. When done all your domains, do a dry run renewal to make sure renewal process is working well too: sudo certbot renew --dry-run

Bonus Section! How to get rid of Letsencrypt Stuff When everything goes bad…

Sometimes we make mistakes and things go wrong with SSL certificates. If you want to rule out Letsencrypt and your certs from the equation, it’s not entirely simple to get it out of your system, as I thought it was. So, here is your bonus section in case you need it nearby:

  1. Disable the letsencrypt conf file: sudo a2dissite prestashop-le-ssl.conf
  2. Totally uninstall letsencrypt (‘certbot’) sudo apt remove --purge python-certbot-apache
  3. Purge these dirs of their certs:

rm -rf /etc/letsencrypt
rm -rf /var/log/letsencrypt
rm -rf /var/lib/letsencrypt
rm -rf /path/to/your/git/clone/directory (seemed not applicable)
rm -rf ~/.local/share/letsencrypt (seemed not applicable)

  1. Wipe all the ssl conf files (which stuck around after wiping the above) in /etc/apache2/sites-available/ with something like:
    sudo rm shop.domain.com-le-ssl.conf
    and sudo rm shop.domain2.com-le-ssl.conf
  2. Restart apache: sudo systemctl restart apache2.service
  3. Restart installation process again if applicable sudo apt install python-certbot-apache

Big Step 10 – Installing Prestashop Via Browser

Go to your var/www/domain.com/public_html/prestashop directory and you should now see Prestashop magically start to do stuff if everything above went well.

You will walk through the install steps and connect the database to the mariadb database name, database user, and database password you created in Big Step 5 above. You will also create a shop admin user and password in the process. When the process is finished, it will warn you to delete your install directory. You cannot log in to your admin area without first deleting this, or, renaming this directory.

To delete it:
Change to where directory is: cd /var/www/shop.domain.com/public_html/prestashop
Remove install directory and all its contents: sudo rm -r install/

To rename it:
Change to where directory is: cd /var/www/shop.domain.com/public_html/prestashop
Move it (which actually renames it), giving it whatever name you’d like: sudo mv install/ install_123abc

Now go to your Prestashop admin area which will be something like domain.com/admin128r78575 (some random characters after the word admin). By the way, you can always find this by navigating to the prestashop directory and just looking for it. This is a nice tip if things go bad 😉

Log in with your shop admin user / password

STOP! Enable and Force SSL HTTPS:// NOW! Do not wait, wonder, etc. If you don’t enable this, things will be bad because your letsencrypt SSL certs are set up and forcing HTTPS:// traffic meaning you’ll never be able to see your shop from the outside without this step. Here is the link again to the post

Note If you happen to get this error while installing Prestashop, you can safely continue as it reportedly does not mess anything major up:

PrestaShop 1.7.5.0 install reports that:
To get the latest internationalization data upgrade the ICU system package and the intl PHP extension”

This is a post I found which indicated this.

Oh, you probably want to rename your Presta-generated admin login directory because it probably made a weird one like admin37dumj777 which means you’d have to log in to your back end at domain.com/admin37dumj777. I did this with this command: sudo mv /admin37dum777 newadmindirectoryname/ which thus ‘moves’ it, or more accurately, renames it and doesn’t move it at all since we didn’t actually change its location. Nice trick, eh?? Now you can log in at domain.com/newadmindirectoryname/

Concluding Comments

I’m tired. That was hard. I hope it helped at least one person besides me. Have a nice day!

Categories
Tutorial Ubuntu Touch

Flashing Ubuntu Touch to your Pinephone’s EMMC memory

You might have already read my first round of ‘flashing 101’ when I successfully flashed Ubuntu Touch to and SD card making it possible to boot the Pinephone that way with Ubuntu Touch. That first blog is a bit more messy because I was learning so in fact, this post here might also help you with flashing to an SD card as it should be more clearly written. If I had more time I’d clean them both up but I don’t so yeah…

The next step in my learning is to figure out how to flash / copy ubuntu touch onto the pinephone’s EMMC (built in) memory. This should make it run faster. There wasn’t a step-by-step that I could find and so I guess I have to write it. Nice folks in the pinephone telegram group said that I would follow a similar method as flashing to the SD card (see my detailed step-by-step on that here so that hopefully is true. Let’s try…

1. Plug in your Pinephone

Unlike my other tutorial, you’ll need the device plugged into your production machine from where the image will be coming.

2. Get latest image

Choose the latest Pinephone image from this page. I choose stable usually but as of today ‘stable’ is a figment of our imagination 🙂 Save it somewhere memorable and probably smart to put it in a dedicated directory so you can run commands more simply and safely. I just realized there is a bmap file sitting with this image download on this page. This could be useful and relevant soon as you read on…

3. Get setup with BMAP

You can just follow my detailed blog if you’d like. If you don’t know what it is, then you probably want to do this.

4. Confirm the source of your ubuntu-touch-pinephone.img.xz file

The file you downloaded in step 2 above which you have on your computer. In my case it’s going to flash from my download directory in my dedicated ‘pinephone_flashing’ directory so mine looks like this:

~/Downloads/pinephone_flashing/ubuntu-touch-pinephone.img.xz

5. Put Pinephone into ‘Yumi Mode’

I didn’t know what else to call this so I named it ‘Yumi Mode’ since that’s the name of the UBports Robot Mascot… I tried to simply plug in the pinephone and do this work but it won’t recognize anything. Thankfully I had read some other tutorial about how to get into this mode. Here’s how

a) Assure device is powered off (you can push / hold power button for about 5 seconds)
b) Press / hold power and volume up buttons together for about 6 or 7 seconds.

If successful, you should start to see a trainload of partitions start to load in your file manager (Nautilus).

6. Identify the destination path to the EMMC

If you’ve done my other blog where you install Ubuntu Touch to the SD card this time we’ll do the same thing but point the destination to the EMMC memory.

  • Hit the super key to the left of the space bar
  • Type ‘disks’ to open the ‘Disks’ utility. You should now see two items related to UT in the left pane of the ‘Disks’ app:

‘Drive | JumpDriv e microSD’

and

‘Drive | JumpeDriv e eMMC’

  • Click the ‘Drive | JumpeDriv e eMMC’ on the left pane
  • Take the path from the ‘Device’ path. In my case it looks like this “Device dev/sdc” but yours can – and very possibly will be – slightly different in the last letter. You can actually just highlight it and copy it from there

path: /dev/sdc

This is a great way to visually identify and confirm which mount point is your eMMC which will help you quickly deal with unmounting stuff in the next section

7. Unmount the partitions on the eMMC drive

If the drive is ‘fully ejected’ by Ubuntu, you will probably get this error when you run the final flashing command:

bmaptool: ERROR: cannot open destination file ‘/dev/sdc’: [Errno 123] No medium found: ‘/dev/sdc’

A reboot of the device again and putting it into ‘Yumi Mode’ again might fix it for you if you are lucky – once this worked for me – but that was it. I do not believe this can be done reliably and thus you should proceed with the command line method. It’s really not that hard if you work together with the Disks utility.

The reason why the ‘eject’ button in File Manager (Nautilus) doesn’t work for this purpose is because ‘it uses udisks ctl which both unmounts and ejects the partition’. We only want unmount, not eject, you see. So, we must ‘terminally unmount’ these as follows:

First, run the mount command which will show you (truthfully) what drives are (actually) mounted on the system. For me these were all located at the very bottom of the terminal output list.

You can, however, in the Disks utility, click through each partition and see at the bottom ‘mounted’ or ‘not mounted` or ‘unkown’ and compare against the terminal output to gain further confidence that you are unmounting and flashing to the right place. The Pinephone image has a mixture of all of these, it seems, so probably better to just manually unmount everything with the terminal. It’s really easy once you identify the actually-mounted drives you just run:

sudo umount /dev/sdc2' sudo umount /dev/sdc4′
etc
etc

**Tip **: If while running the final flashing commands you get this error:

bmaptool: ERROR: the image file ‘/home/wt/Downloads/ubuntu-touch-pinephone.img.xz’ has size 826.3 MiB and it will not fit the block device ‘/dev/sdc3’ which has 1.0 KiB capacity

You are probably writing to a partition like I did instead of the actual device. You probably put in /dev/sdc3 instead of /dev/sdc as an example.

8. Run the flashing command

This assumes you have alread set up and read and understand my blog above.

Format:

sudo bmaptool copy --bmap ~/path/where/your/bmap/file/is/located /path/where/your/image/is/located /path/to/memory/device

My actual example:

sudo bmaptool copy --bmap ~/Downloads/pphone.bmap ~/Downloads/ubuntu-touch-pinephone.img.xz /dev/sdc

Worked for me! Hope it works for you too 🙂

Categories
Technology Tutorial Ubuntu Touch

How to do an Ubuntu Touch Video Screen Cast Recording

Making a video screen cast of your Ubuntu Touch (“UT”) device is a bit difficult as of the date of this blog post, however, thankfully, there is a way to do it with a bunch of scary terminal commands.

This is pretty technical, but is probably the only way (for now) to do this. Special thanks to Amolith who forwarded to Joe (“in here”) who then forwarded it to me. The power of free software communities at work!

First, I’ll just give you the commands in case you are already familiar enough with terminals and commands. Then, I will provide detailed how-to to follow.

Record a big raw video file in interesting .raw format

EDIT 20/06/21
This first command has been updated to reduce ‘terminal weirdness’. Now it works quietly in the terminal. Special thanks to Rodney for that excellent improvement.

adb exec-out timeout 120 mirscreencast -m /run/mir_socket --stdout --cap-interval 2 -s 384 640 > ubuntu_touch.raw

Convert it to ‘normal’ format (mp4) with ffmpeg tool

ffmpeg -f rawvideo -pix_fmt rgba -s:v 384x640 -i ubuntu_touch.raw -filter:v "setpts=2*PTS" ubuntu_touch.mp4

I plan to give a few more how-to details next by editing this blog post but for now I at least wanted it logged somewhere where myself and others can easily find it.

Enjoy

Tutorial – How to actually do it.

Before you begin

I would recommend creating a directory / folder just for doing this stuff. Then, you will navigate in your terminal to this directory. That makes sure that all the video is dumping in a place where you’ll be able to find it and work with it easier. Otherwise, your terminal might autonomously dump it an undesired location (your Home directory if you left everything default…). Once you have created this directory, navigate to it with the terminal’s ‘cd’ command. If you don’t know how to do that, take a few minutes to search and learn? It’s a good life skill and you can brag about it at the coffee machine or water cooler…

Now that you have the scary command line codes above ready to copy and paste, here’s how you do it and what to expect.

First, you’ll have to make sure you have adb setup on your ‘production machine’ (the machine that is recording the Ubuntu Touch output video. You should be ok to just do the usual sudo apt install adb and then perhaps you’ll need to be in ‘Developer mode’ to do all this. You might find that your system already has adb. If so, it will tell you that your version is up to date, etc and you can continue. If you need either of these or find it’s not working right, this blog has a lot of good info in one place. Most should be current still at the time of this post.

Next, plug in your UT device and get ready to record. Probably a quick test video is wise, by the way, before you start recording a long meaningful video.

Next, run the first command above by copying/pasting into your terminal. You will see this (or something very similar) in the terminal. Just pretend this means “your raw video is now recording to your production machine” because that’s what’s happening even though you can’t see it:

daemon not running; starting now at tcp:5037

daemon started successfully

When you are done recording, go back to your terminal and press ‘control C’ in to stop the process. You will see absolutely nothing except your ^C. Just pretend this means ‘Your raw video file has now stopped recording and is sitting in the directory where you started it”.

Finally, you’ll need to convert the raw video to a human-usable format – and probably mp4 is what you’re looking for which is why the above command is setup the way it is. Note that if you want to do any other million different things with your video work, you could study the power of ffmpeg and do whatever you like with formats, resolutions, etc, etc….

Now, in your terminal after you run the converting command, you are going to see a lot of ‘stuff’ in your terminal. I’m not going to even paste it here because there is so much. I’m also not going to pretend I know what any of of it means. Just be aware this is ‘normal’.

Once complete you should now have a .raw video and a .mp4 video in your screen casting directory.

Double click your .mp4 file to make sure it’s working and enjoy your new Ubuntu Touch video screen recording.

Categories
Tutorial Ubuntu Ubuntu Touch

Flashing Ubuntu Touch onto SD Card for Pinephone Braveheart Installation

EDIT 20/06/19
I have done a fairly extensive post about how to use BMAP properly so here is a link to my post. You should probably read this to know that the true benefits of speed from Bmap tools comes from following the instructions in my other blog. Otherwise, you might as well just use ‘dd’ or other flashing techniques. Bmap is indeed faster!

EDIT: 20/06/14

I tried with Etcher and had problems booting (not sure this was actually the cause) so now I’m trying with a tool recommended bmap-tools by someone in the Pinephone Telegram group. This tutorial includes instructions for getting set up and using this bmap tools tool.

This tutorial assumes you are running Ubuntu on your desktop/pc/laptop…

It’s a command line tool, it seems so yeah. No GUI. Hopefully my commands and instructions will remove the CLI mystique…

Apparently bmap-tools also automatically unzips/uncompresses your ubuntu-touch-pinephone.img.xz image as well, so you don’t have to do that step before.

  1. Get Ubuntu Touch image currently here
  2. Install to ubuntu: sudo apt install bmap-tools
  3. Confirm the source of your ubuntu-touch-pinephone.img.xz file which you have on your computer from this instructional page your source and destination addresses. In my case it’s coming from my download directory and going to my SD card so my source location looks like this:

~/Downloads/ubuntu-touch-pinephone.img.xz

  1. Confirm the destination path of your SD card. This step is important because if you goof this you risk (probably) writing your image to the wrong drive and killing it. How I do this is
    a) Hit the super key to the left of the space bar
    b) Type ‘disks’ to open the Disks utility
    c) Click my SD card on the left pane (graphically)
    d) Take the path from the ‘Device’ path. In my case it looks like this “Device dev/mmcblk0p1” You can actually just highlight it and copy it from there
  • path: /dev/mmcblk0

Important note on this last step: I had a lot of annoyances in the terminal related to ‘memory errors’ and it was because I had copied the entire item. In my case it looked like this: mmcblk0p1. Make sure that you do not have anything like ‘p1’ or ‘p2’ on the end of your destination path. These are for ‘partitions’ and is the incorrect path. should be just : /dev/mmcblk0not something like this –> /dev/mmcblk0p1. If you run it with the latter you will get those memory errors like me.

Just to leave it as reference the errors caused by the mistake above look like this:

bmaptool: info: no bmap given, copy entire image to '/dev/mmcblk0'
bmaptool: WARNING: failed to enable I/O optimization, expect suboptimal speed (reason: cannot switch to the 'noop' I/O scheduler: [Errno 22] Invalid argument)
/
bmaptool: info: synchronizing '/dev/mmcblk0'
bmaptool: info: copying time: 17m 13.1s, copying speed 13.5 MiB/sec
  1. Run the command
    Pre-cautionary step 1: remove all external drives before doing any of this.
    Pre-cautionary step 2: Other tutorials I read did not explain that you should unmount your drive before beginning. So in your Nautilus just go through and ‘eject’ anything showing up as ‘ejectable’.

As a reference, this tutorial was helpful for tool usage but still not quite clear enough so I’ll go even slower…

EDIT 20/06/14 – Apparently this next bit of my advice is bad and slows down the process. Apparently you should just make sure you run the command in the same directory as the image, and then it will work faster and without the need for the –nobmap tag. I will leave this here as a reference just in case you need it but as of today it was advised to not follow it:

—-

With bmaptool when you are doing straight flashing you can just add the --nobmap tag to the command, which I think means ‘just do this thing without routing through other specific instruction file’. So that’s what I’m going to do.

—-

I am still not 100% sure if this step is required, but it helped me so I’m leaving it as a reference: I also got some ‘no space left on device’ errors so I decided to first format the drive with Disk tools before trying again. I did this by opening the ‘Disks’ graphical utility again by clicking the SD card I wanted to format and then selecting ‘format disk’ from the top right hamburger menu. Takes about 2 seconds to wipe whatever is on there… after doing this step everything finally started working better. I created a linux ext4 partition next to see if that helped. I made the first partition with 21GB (for the image) and then a trailing 10GB for ‘whatever’. These were just choices I made thinking that I could maybe use the trailing 10GB for phone storage.

Here are, therefore, the steps, assuming you have done all of the above:

  1. Open the terminal
  2. Make sure you have navigated (with terminal commands) to the directory where your image is
  3. Type the following command replacing the source and path with whatever is correct from your device as per instructions above:

bmaptool -E copy /path/to/ubuntu-touch-pinephone.img.xz /path/to/SD/card

My example that finally worked looked like this for your reference:

sudo -E bmaptool copy ~/Downloads/ubuntu-touch-pinephone.img.xz /dev/mmcblk0

Boot it

Apparently just inserting the SD card and turning the power on should do it, but yeah. Depends on a ‘few things’ as to whether this will be your experience 😉

This was actually harder than I thought. I’m not sure if this was the cause of my pain but I’m going to list it anyways. I had to do about 100 reboots and it still wasn’t working. I couldn’t seem to get past the ubuntu purple splash startup screen. I ‘think’ I had interrupted a process the first time so i did all of the above steps againb but this time I held down the power button until the green indicator light came on and then everything started as expected and I was able to start using Ubuntu Touch. Members of the community indicated it may be related to a faulty build and to try other build numbers to see if that helps. We shall see.

Issues flashing cards

I had an interesting issue where I couldn’t unmount a card. System said ‘not mounted’ when I tried umount command. Amazingly, just a reboot of computer allowed the ‘Disks’ utility to start working again as normal. Others were reporting that one should consider using gparted tools instead of Disks utility just as another related tip if you are interested.

I hope this helps and have a great day

Resources

Pinephone images for Ubuntu Touch here

How to telnet into the device here

My bmap tools tutorial here

Categories
PrestaShop Technology Tutorial

Fixing PrestaShop child theme upload fail

Just a quick post. To be totally honest, I haven’t had time to investigate if this is a filed bug or not, but I’m going to post this here to save others some headaches and also hopefully serve as a reference link for someone else if they want to file the bug officially (sorry, my bad).

I tried to upload a child theme in the prestashop theme section but kept getting this message in the ‘upload child theme’ feature:

Oops… Upload failed.
What happened?
Try again

However, when I clicked the ‘what happened’ link it only told me that the file wasn’t valid (in this case I was uploading a .zip which it instructed me to do) so the file was valid.

To make a long story short, what I had to do to get it working was this in the Theme & Logo / Advanced Customization area:

  1. Switch back from my already-uploaded first-attempt child theme to the original parent theme
  2. Delete my first child theme upload attempt with same name
  3. Upload the new Child theme

If I’m correct in my assumption that the ‘technical name’ of my first uploaded theme is conflicting with the new upload attempt, this should be clearly laid out in the upload area and a few other areas so that the user knows ‘ah! i should delete any conflicting child themes first!”

Again, I haven’t tested this more than twice but hopefully this helps the devs and some users

Categories
Life Skills Technology Tutorial

How to Import Shopify Data into Prestashop with CSV

Brutal. I spent probably 3 hours trying to figure this out so I thought I should spend about 10 minutes and write this quick blog post for anyone else who might hit this.

I was testing out Prestashop (looking good so far!) and the aim was to move a new shopify account over to Prestashop to see how it goes.

First thing I did was had the Shopify product data exported as .csv file.

Next I followed the instructions on the documentation page for importing into Prestshop. Unfortunately, though, there seemed to be no detailed instructions about how to set up data. I think this is because there are a lot of migration companies that make some cash doing this so fair enough.

Anyways, what I did was opened up both Shopify .csv and Prestashop demo .csv for products and noticed that they both have different data separator formats.

Shopify uses commas whereas Prestashop uses semi colon.

So, all I had to do was manually type in a comma into the field that says ‘Field Separator’ in the Prestashop import module and everything started working and I could start mapping the fields and database tables as expected and as explained in documentation.

Hope this tiny, one second tip helps you save 3 hours and some cash.