Categories
Business Technology Tutorial Ubuntu

Installing Formtools on a Server with WordPress

I’m not sure how niche this need is but I was in need of making a quick website and then suddenly needed a quick but robust web form tool. I I thought for sure I had written at least a blog or two about this awesome tool at formtools.org but apparently I have not. I deeply apologize to all the folks and contributors of this awesome and free and open software project. This is indeed the ‘swiss army knife’ of web form tools and I would love to write more about it one day.

For now, I will simply map out how I got the tool working for this specific need.

Disclaimer: I am an untaught system administrator meaning “I learn as I go’ so if there is a better way to do this, cool. I just search a solution and figure it out as I go until it works and improve as I go.

More precise disclaimer:

If you run this tutorial and set it up like I did, keep in mind you will have to back up the hard files and database SEPARATELY of course since this thing has nothing to do with WP and runs by itself. So if you change servers, upgrade WP etc, it will probably wipe it out since it’s in the same directory. Who knows. Probably this ‘forms’ directory we’re creating should live in a totally separate directory outside of WordPress (“WP”) and then have a separate configuration file created in /etc/apache2/sites-enabled/ directory and point to the root that way. However, I just needed it up and going for now so I stuck it in the /var/www/html directory where the rest of WP was functioning perfectly.

Before you begin

Assumptions

  • This assumes you are running an ubuntu server for your WP install
  • You have your super user sudo user (or higher) at your server
  • You already have your WordPress site up and running.

Get Formtools Zip File on Local Machine

  • Install ‘unzip’ tool on your ubuntu server with: sudo apt install unzip
  • Download the most recent Formtools zip file from here somewhere on your local machine. I tried to curl it there. I tried to wget it there, and many other attempts but seemed to keep failing. Hence this method. It seems sftp comes installed on most ubuntu installs which is a great tool – I didn’t even know about before I wrote this post.
  • On your local machine, with command line, navigate to directory where your downloaded formtools zip file is located with cd command

Put the Formtools Zip File on your Ubuntu Server

You can do this with FTP client or whatever method you like but I really like this sftp tool… quick and easy, works just like ssh.

  • In directory where zip file is, connect to WP ubuntu server: sftp username@wordpressserverIPOrDomain.com
  • Enter password
  • Put zip file on server (goes to home directory): put FormTools3.0.20-20191109.zip (of course adjust filename if it’s different)
    Should print out something like this:
sftp> put FormTools3.0.20-20191109.zip 
Uploading FormTools3.0.20-20191109.zip to /home/sysmin/FormTools3.0.20-20191109.zip
FormTools3.0.20-20191109.zip                  100% 8995KB 753.7KB/s   00:11 
  • Type ‘exit’ to get out of sftp thing

Setup Your WP Ubuntu Server for Formtools Installation

  • ssh into your WP server:
    ssh username@wordpressserverIPOrDomain.com
  • Move to your WP directory:
    cd /var/www/html/
  • Create a directory name where your forms will live. NOTE: Make this directory name logical since your forms will have this URL in it. In this case I chose ‘forms’ as the name but do what you feel is best:
    sudo mkdir forms
  • Move back to your home directory on server where your uploaded .zip file shold be sitting
    cd ~
  • Move the zip file to the new directory you made in the midst of your WP install directory:
    sudo mv FormTools3.0.20-20191109.zip /var/www/html/forms
  • Go there to make sure it made it there:
    cd /var/www/html/forms
  • Assuming it made it there, unzip it there:
    sudo unzip FormTools3.0.20-20191109.zip
  • Print what you have in the directory to see that you have both the original Formtools zip file and the newly extracted non-zip version:
    ls
  • Remove the original Formtools zip file as you shouldn’t need it again:
    sudo rm FormTools3.0.20-20191109.zip
  • Get rid of the Formtools directory (a bit long) and move all the files within, one level up into our custom-created ‘forms’ folder where we currently are. This command says, with the * asterisk, ‘move everything in the formtools directory to the /var/www/html/forms directory.
    sudo mv -v formtools/* /var/www/html/forms/
  • Everything should now be good. Might as well wipe away the now-empty ‘formtools’ directory:
    sudo rmdir formtools

Assuming you did everything here you should now be able to go to your domain name where your WP is installed ‘yourdomain.com/forms’ in a browser and be greeted with the install script page for Formtools. From there you’ll have to do your own study on this great tool but hope this helps.

Setting Correct Permissions

After running the pre-flight stuff for the first time I got notified that the ‘upload’ and ‘cache’ directories did not have write permissions. I’m not sure if this will happen to you so I thought I should log it for all of us:

  • Set the owner of the newly created ‘forms’ directory to ‘www-data’ (adjust as you need). the -R sets the owner down the whole directory: sudo chown-R www-data:www-data /var/www/html/forms/
  • Assign the correct permissions to the same directory: sudo chmod -R 755 /var/www/html/forms/

For full disclosure the first time I did these commands I had issues with permissions. However, after messing with permissions again and running exactly as per above, it started working so my theory is that I goofed something in those first commands. If you run into headaches, try assigning permissions again to the main forms folder separately with sudo chmod 755 /var/www/html/forms/ (assuming you are in the html directory when you run it) and then again with the -R sudo chmod -R 755 /var/www/html/forms/. At one point I put the dash in front of the 755 and yeah… don’t do that. HA!

Create the MariaDB Database

Go figure! I thought this thing was going to magically auto-create me a data base but it looks like no such joy shall be mine. Good thing is that I already suffered the pain of learning how to create a database with MySQL so I’ll plop those instructions here and follow them again:

I thought that WP would come with Mariadb version of mysql but it does not. It’s some other version but some of the commands still work.

  • Log in to mysql: sudo mysql -u root -p
  • Enter password: .. I used my Digital Ocean’s sudo user’s password / root user and it seemed to work. What are the odds? woot woot. If you are on a different system you’ll probably have to walk the the setup of a secure mysql admin user/password.

Now I’ll try to create my database with the database name that I already saved to my password manager above. I’ll call the database ‘forms_db’ :

  • Create database with database name ‘forms_db’ (you can call it what you’d like):
    CREATE DATABASE forms_db;
  • Ceate 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';

Looking good…

On MariaDB I used to do this, but apparently WP comes with some other MYSQL thing and this next command does NOT work:

GRANT ALL ON forms_db.* TO 'username_here'@'localhost' IDENTIFIED BY 'same_password_here' WITH GRANT OPTION;

  • I searched online and found this which ultimately worked whatever version of mysql WP uses:

GRANT ALL ON forms_db.* TO 'username_here'@'localhost;'

got this response which ultimately seemed to indicate it worked:

‘Query OK, 0 rows affected (0.00 sec)’

  • Flush it like you mean it: FLUSH PRIVILEGES;
  • Get outta dodge: EXIT

yay. got outta dodge…

Finishing Install of Formtools

Now, back to the Form Tools install (yourdomain.com/forms) page now that I have some database user stuff to enter. Here is what I stuck in there, mainly leaving the defaults:

1. Enter Formtools Stuff

database hostname: localhost
datbasename: forms_db
port: 3306
Database username: 'username_here'
Datbase password: 'same_password_here'
Database table prefix: ft_

2. Accept config file
The next screen ‘Create Config File’ seems to be a friendly heads up that it will automatically create the config file based on the info you are submitting. I will accept their friendly offer and click ‘create file’ button.

This went well too.

3. “Create Admin Account”
This part is to give your admin user power over the tool box, much like your wordpress main admin user. Nothing complicated here, fill in the username and password stuff and save credentials safely in your password manager or on the sticky note beside your monitor like most people, har har.

4. Finish up

I got a ‘Clean Up’ message with a ‘Congratulations, Form Tools has been successfully installed!’ so that’s also looking good.

There is a green “log into Form Tools’ button that appears. After clicking it I was greeted with user / password fields and I used the credentials we just created above which successfully logged me in.

Don’t forget my disclaimer at the top. I’m not a qualified system admin. I’ll therefore paste this warning again so you can plan accordingly and adjust:

If you run this tutorial and set it up like I did, keep in mind you will have to back up the hard files and database SEPARATELY of course since this thing has nothing to do with WP and runs by itself.  So if you change servers, upgrade WP etc, it will probably wipe it out since it's in the same directory.  Who knows.  Probably this 'forms' directory we're creating should live in a totally separate directory outside of Word Press and then have a separate configuration file created in /etc/apache2/sites-enabled/ directory and point to the root that way.  However, I just needed it up and going for now so I stuck it in the /var/www/html directory where the rest of WP was functioning perfectly.

The next part is learning how to use form tools which isn’t super intuitive the first round but very powerful. I hope to do a series on this one day but for now hopefully this helps someone.

Have a great day!

Categories
Business suitecrm Technology Tutorial Ubuntu

HOW TO INSTALL SUITECRM ON UBUNTU SERVER

Suitecrm is absolutely awesome, free and open software to run your organization or business. I’ve messed around with various crm’s like Salesforce but SuiteCRM is just so flexible. Oh, and it doesn’t cost any money. Oh, and if you need help or other stuff you can just pay people to build what you need. I haven’t explored all sectors but most business owners I know have found it to be excellent.

I thought I would have to write a long, detailed tutorial on this but thankfully I landed on this really excellent step-by-step tutorial.

I think there is a better way to install PHP, though, rather than copying all those individual PHP packages, but I’m too busy to look that up now. You can try, but this tutorial works. My only concern is that these packages and requirements might change over time so the one-stop-shop for installing all php packages is probably the better way to go.

I followed all the instructions in this tutorial above and successfully ended up with SuiteCRM running on my Ubuntu server on Digital Ocean droplet platform.

However, there were two things not covered which are important:

  1. It was not SSL encrypted HTTPS:// so at the end of all the installation stuff, I needed to do that and
  2. There was no mention of the important step of setting up the cron jobs which is one of the life-blood features of SuiteCRM since it is very good at sending out workflow reminders and other alerts by email. Cron jobs control this. The instructions are on the install page of the last step, as you can see, but I will make it more clear with a start-to-finish tutorial as follows:

Big Step 1 – Set up the Digital Ocean Droplet

  1. Make sure you already have a domain purchased and reserved for your needs. This is optional but I will assume you’re doing this for tutorial.
  2. Initiate your server / droplet
    I won’t give detailed instructions here because there is lots of documentation out there. I selected one with 2GB of ram (at time of writing it’s $10.00 uSD /month for this) only because the teacher recommended it. I didn’t research hardware specs and what I should do. Your needs may be different. I know using Nextcloud Talk uses a bit of RAM but not sure how much for a large conference.. worth investigating perhaps? I might also recommend calling your subdomain ‘nc’ instead of ‘files’ like I did in my example since you might do much more than ‘files’ with NC. “office.domain” or ‘nc.domain’ or ‘cloud.domain’ might make more sense?
  3. In your domain registrar, point your domain to your server’s name host. In my case it will be digital ocean’s which I will pull from the ‘networking’ section after adding the domain to Digital Ocean. In my case I already had a test domain setup, so what I did was set up a subdomain called “files.domain.com”. The reason you want to do this right away is because
  4. 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…). If you already have a DO space and SSH keys setup, you are already ready and can use those keys again.
  5. SSH into your new server
    ssh root@123.123.123.123

Note 1: Normally at this point when I install a server I do the usual sudo apt update and sudo apt upgrade but the main install script for Postal does this for you it seems.

But… you don’t have a sudo user yet so here you go:

Big Step 2 – Make a sudo (non-root super user) user

Set up a non-root user account on the server. This is to reduce your chances of typing a wrong command and killing all your hard work and data.

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…

Big Step 3 – Install SuiteCRM

Installing SuiteCRM, as mentioned above, is as simple as taking the time to follow this really excellent step-by-step tutorial

Big Step 4 – Secure your Installation with LetsEncrypt

SuiteCRM is good for moving company and organizational data, so you better protect that data with encryption.

  1. Add the PPA: sudo add-apt-repository ppa:certbot/certbot
  2. Install the certbot: sudo apt install python-certbot-apache
    Note: on Ubuntu 20, it seems to be this one now, so check if you hit any snags: sudo apt install certbot python3-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 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…
  10. Test your domains here to make sure https:// is working. Try going to them in a browser to see if you can still reach the SuiteCRM pages and then the lock icon is on. If not, make sure you’ve typed in https:// before URL. In the future, if you chose ‘redirect all’ in steap 9 above it should not require typing the https:// unless there is a problem.
  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 SubSection! How to get rid of Letsencrypt Stuff When everything goes sideways
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)

BONUS SECTION – Little Tips on Install Page

From the SuiteCRM install page, a few things I had to spend time learning that I think are worth sharing are:

  • the ‘upload’ button on the logo in the ‘branding’ section doesn’t seem to work at that stage. Does it work if you point the file to directory and then not push upload? to confirm…
  • If you have an email setup that will send emails from the system, then you can have that ready. If you are just doing some testing you can use some fake gmail account if you want, I suppose. Otherwise, if you don’t fill anything in it doesn’t hinder your installation, but you will not have the important email notification functionality.
  • The default install script automatically auto-filled my host field as my website domain. Then I got this error message in red: “The provided database host, username, and/or password is invalid, and a connection to the database could not be established. Please enter a valid host, username and passwordThe provided database host, username, and/or password is invalid, and a connection to the database could not be established. Please enter a valid host, username and password”
    After I changed this auto-filled domain back to localhost (like in the tutorial screenshot) in the host field and pressed ‘next’ everything rolled ahead smoothly again.

Now that you are set up with SuiteCRM, there are a few ‘housekeeping setup things’ I do right after installation, such as cron jobs, setting up your email, etc. You can check that out on my SuiteCRM Post-Installation Housekeeping

I hope this helps you get started with the best CRM around!

Categories
suitecrm Technology Tutorial

SuiteCRM Post-Installation Housekeeping

If you’ve been following along any of my other SuiteCRM (“SCRM” from hereon in) blog posts, you’ll know that I’m a big fan of this free and open SuiteCRM software project. As such, I do my best to document things that are either easily forgotten or difficult to find online. Hopefully some of this is valuable to you.

1 – Setting up Basic Outbound Email for Functionality

The built-in email functionality of SCRM is not just for sending emails to people with relative ease (which it can do right inside the interface) but also, if not more importantly, it serves to deliver messages from the Workflow module. For example, if you have a task due and you want an email to remind you, this does that. If you don’t set up the email you will only be able to log in and see your tasks.

This gent did a great, slow and methodical Suitecrm email setup video so it is definitely worth the 7 minutes if you haven’t done this before.

I would like to make a few additional comments, though, on the following points:

“Outbound Email” in Admin

When I first started using SCRM I started by adding an ‘outbound email’ server in that specific spot. However, this seems to not be required / redundant. When you go into ‘Email Settings” and do all the items in the video above, an outbound email server is automatically created. I am not sure why there is access to this via two doors. Perhaps to do a quick adjustment (such as a password change?) later? But you can also do that in “Email settings”. I feel better notes should be left in the “Outbound Email’ section user interface to explain, but until then, unless you have a reason, simply don’t use this section and do your adjustments / setup in “Email settings”

Spam Protection Headaches

I have had a repeated issue where I can perfectly send test emails from SCRM to any email address except an email address that shares the same domain name. For example, let’s say my email in SCRM is wayneoutthere@example.com. I can send perfectly to wayneoutthere@whatever.com but emails sent to bob@example.com don’t make it through. I don’t yet know the technical reason for this but it could be something as simple as the server not yet being ‘warmed up’ and still possibly on a ‘spam radar’ or worse yet, a spam blacklist.

As such, I would always start your email setup with a test email to various email addresses that do not share a domain with the system-sending email address as well as emails to ones that do share. It’s very important, obviously, that emails from the system make it to your organization’s email addresses – that’s the entire purpose of the system! If all else fails, and you don’t care about privacy and security, you could probably set up a quick gmail address to do the sending, but this doesn’t look good from a professionalism standpoint or data privacy.

POSSIBLE / PROBABLE SOLUTION TO EMAIL SEND FAILS TO INTERNAL EMAIL ADDRESSES
For me, the cause of the problem seemed to be the fact that I changed the "From" Address: * field to an non-existing account called ‘do_not_reply@’ So, the ‘real’ account (the one that had legitimate SMTP server credentials) was ‘orders@’, but I entered ‘do_not_reply@’ and this caused emails to fail to internal email addresses. My theory is that the email service provider has some anti-spoofing technology going on that said ‘Hey. This email came from an SMTP thing on the internet using your domain when an account called ‘do_not_reply’ doesn’t actually exist. They might be spoofing you!’ However, this still doesn’t explain why all the do_not_reply@ emails successfully were received by various gmail and other emails. Anyway, consider making a dedicated, real, email address just for this sending if you encounter this issue.

2 – Jobbing your Crons

As mentioned above, the Workflow module is very powerful and can send messages as well as part of an ‘event’. As described on the /install.php page of SuiteCRM (if you recall), in order to enjoy the full power of the Workflow module, you need ‘cron jobs’ working as per requirements mentioned on install page. Not only that, but SCRM has other internal ‘things’ it needs to do (such as indexing) which require this to work. In short, just do the following instructions from the install page now, but, be careful of one thing and that is to make sure that your folder is actually named ‘suitecrm’ and that it’s located at /var/www/html/ otherwise, adjust the path in the following accordingly:

This is a copy and paste from the installation page in case you didn’t note it:

To Setup Crontab
In order to run SuiteCRM Schedulers, edit your web server user’s crontab file with this command:
sudo crontab -e -u www-data
… and add the following line to the crontab file:

  • * * * * cd /var/www/html/suitecrm; php -f cron.php > /dev/null 2>&1
    You should do this only after the installation is concluded.

If the above wasn’t clear enough for you, here is my detailed explanation:

  1. ssh into your SCRM server
  2. Open the crontab file for editting: sudo crontab -e -u www-data
    Note: if this is the first time creating a crontab file on an ubuntu machine, you will be told so and it will automatically start a fresh one for you. You will be prompted to choose a text editor and it will also advise nano (option 1). Choose this default if you aren’t sure since all you need to do is paste a line of code at the bottom
  3. Copy this line of code: * * * * * cd /var/www/html/suitecrm; php -f cron.php > /dev/null 2>&1
  4. Paste it to the bottom of the crontab file
  5. save changes (control x, enter, etc)

I also had an issue where my cron jobs didn’t start, so it was advised around the internet to run this restart command on it to be sure:

sudo service cron restart

Your crontab stuff is now complete.

You can see if things are working by going into Admin / Schedulers and looking at some regularly-occurring items to see the job logs. Choose one with an interval of ‘As often as possible’ and this will give you a good idea if it’s working.

You can also go to Admin / System Settings and at the bottom view the logs to see if there are any errors if things are supposed to happen but don’t seem to be. Note it’s not intuitive but you have to actually click the job log menu to show any results. It looks blank otherwise. A bit weird indeed. There should at least be an icon to show you that you could /should click it, but it’s not there yet.

Note this tip from documentation, too, in case it affects you:

If you were running your cron jobs as root for some time, due to a wrong crontab configuration, after you fix it, remember to reset correct >ownership and permissions on the entire SuiteCRM directory tree, and then do a Quick Repair and Rebuild

The ‘Quick Repair and Rebuild’ is quite amazing at fixing things you don’t even understand. 🙂

3 – Setting up some Pretty Critical Missing Fields

Payment Method

Surprisingly, this very important field “Payment Method” is missing in both the Quotes and the Invoice module. It’s easy to create but I thought I would provide a quick and easy resource where you can come back here and re-create or create it quickly without doing so much thinking.

First, Quotes module:

  1. Go do Admin
  2. Studio
  3. Hit the home icon which magically takes you to the secretive ‘Dropdown editor’
  4. Click ‘Dropdown editor’
  5. CLick ‘Add dropdown’ button
  6. add ‘pay_method’ before the ‘_list’ in the Name: field at the top
  7. Start building the list as follows (you can copy and paste mine or change the items and the order as you like) hitting the ‘Add’ button after each one is completed:

ITEM NAME | DISPLAY LABEL

credit_card | Credit Card
cheque | Cheque
e_transfer | Email Transfer (E-transfer)
eft | Electronic Funds Transfer (EFT)
cash | Cash
wire_trans | Wire Transfer
bitcoin | Bitcoin

(OPTIONAL: Add a blank entry if you want the option of leaving the payment method blank when users are choosing the payment method. Otherwise you’ll be forced to select one as a default – you do this by pushing the ‘ADD’ button with nothing in the item name or display label fields.

  1. Hit save – you should get the ‘This operation is completed successfully’ message

Now you have your Payment method dropdown but you don’t yet have a useable field so let’s make that next.

  1. Hit the home button to go back up a level
  2. Go to Studio
  3. Go to Quotes
  4. Fields
  5. Add Field
  6. Choose ‘dropdown’ drom the ‘Data Type:’ list at the top
  7. Field name: ‘payment_method’
  8. Display Label: ‘Payment Method’
  9. Drop Down List: search for the one you just made above called ‘pay_method_list’
  10. Choose default value
  11. “Save”

Congrats! You now have a usable field but you do not have a visible field – so… it’s still useless. Let’s make it visible:

  1. Studio (you’re getting good at this now!)
  2. Quotes
  3. Layouts
  4. Edit view
  5. Drag a ‘New row” button over to the ‘Overview’ panel
  6. Drag your new ‘Payment Method’ field onto new row from the left column (you should see it there)
  7. Arrange remaining fields however you like
  8. “save and deploy’ to save and launch your changes
  9. Go create a new quote, and make sure that your changes exist in “Edit View’ after pressing ‘edit’ button in quote

If everything went well, you now have a fully-functional ‘Payment Method’ field in the Quotes module of SCRM.

Update the Detailed View
Now you can repeat steps 1,2,3 and then select ‘Detail View’ and repeat steps 5, 6, 7, 8 to make the same fields visible in the “Detail View’ (the view before you hit the edit view)

Create fields for Invoice Module
Now, let’s repeat the same thing for the invoice module since we’ll need it there too. However, we’ll also want the contents of the quotes module field to convert to the invoice during conversion when the user clicks ‘conver to invoice’. This will happen if we give the field the exact same name in the Invoice module.

I would advise opening the following up in a separate browser tab for convenience: Studio / Quotes / Fields / ‘payment_method_c’ (the one you created above in the quotes module)

Now in a new tab do the following:

  1. Studio
  2. Invoices
  3. Fields
  4. Add Field
  5. Choose ‘dropdown’ drom the ‘Data Type:’ list at the top
  6. Field name: ‘payment_method’ (Exactly the same as you did in Quotes field above)
  7. Display Label: ‘Payment Method'(Exactly the same as you did in Quotes field above)
  8. Drop Down List: ‘pay_method_list’ (Exactly the same as you did in Quotes field above)
  9. Select your default entry, if any
  10. Save
  11. Refresh the ‘Studio / Invoices / Fields’ list to makes sure you see your ‘Payment Method’ field appear (probably near bottom)

If everything is good, you now should have a fully functioning field, which can receive the data from the Quotes module when the user clicks ‘convert to invoice.

The second last steps, as always, is to make it visible to the user and usable via the ‘Layouts’ feature.

  1. Studio
  2. Invoices
  3. Layouts
  4. Edit view
  5. Drag a ‘New row” button over to the ‘Overview’ panel
  6. Drag your new ‘Payment Method’ field onto new row
  7. Arrange remaining fields however you like
  8. “Save and deploy’ to save and launch your changes
  9. Go create a new Invoice by itself (ie. not by converting from a quote to an invoice), and make sure that your new fields exist in the Invoice as an option and that all the dropdowns are working as expected. If everything looks good, go back in and add the same fields to your ‘detail view’ (instead of Edit view) in layouts if youw want to see those same fields after saving and leaving edit view.

If everything is now satisfactory, let’s proceed to the last step which is testing to make sure the new fields make it through an Quote-to-Invoice conversion.

Test the New Fields Through the Quote-to-Invoice Conversion Process

  1. Create a new fake test quote in Quotes module
  2. Make sure your new field(s) have data in them
  3. Pay special attention to exactly what data you put in each test field because you’ll need to check this.
  4. Save your quote
  5. Click the ‘Actions’ button
  6. Select ‘Convert to Invoice’
  7. Did ALL fields perfectly convert over?

If so, you are good to go.

If not, there is probably a problem with the field name. As mentioned above it has to be exact or it won’t make it through conversion.

In my case, I had a failed conversion. The issue was because I had typo’d the field name in the Invoice module and it didn’t perfectly match the original quote module hence – failed conversion. I had to delete the Invoice field and start all over again and recreate it exactly. That’s why we test early and not after we’ve created 10 real quotes, ha.

4 – Dealing with the “Terms” Field and Other Hard-coded Fields

SCRM by default, appends a _c to the end of any custom field that you create. This has a purpose and that is to make sure that your custom fields don’t die when you upgrade your SCRM install. However, in this case, it’s a pain because let’s use the out-of-the-box field name ‘term’ that comes in the Quote module. This field is used to put the poorly spelled ‘Nett 15’ payment terms on the quote. So, I thought I would wisely add a field in the Invoice module (it’s oddly missing as mentioned above) and give it exactly the same name and watch it work.

Nope.

There is no way to create a field called term because it’s hard coded in the system. When you attempt to create it it will automatically create term_c which, as we know, is not a match and won’t make it through conversion from Quote field to Invoice field.

As such, the workaround for this situation is as follows:

  1. Create a replacement field for the original ‘term’ in Quotes (first). Give it a better name such as payment_terms. This will create a field called payment_terms_c after saving the field. (see instructions above for more details)
  2. Map it to the correct drop field down as per instructions above
  3. Remove the original out-of-box term field from the layouts (effectively archiving it from use forever since no users will be able to see it) – see instructions above for changing layouts
  4. Rename the original term field to ‘Payment Terms-OLD’ in the Display Label field for this field (just trust me otherwise it’s a recipe for pain if it shares the same Display Label)
  5. Insert your newly-created replacement field (payment_terms_c) into the layouts where the old one was. Note: Be sure to do ALL layouts including ‘quick create’ or it will bite you later.
  6. Save and deploy

Now you have your Quotes module field ready to go. Now you just follow the instructions above and create an invoice field with the exact same payment_terms_c field name… or is it ‘payment_terms’… let’s see…

Payment Terms

As mentioned above, the ‘payment terms’ dropdown list has spelling errors (Nett 15, Nett 30) and it’s basically void of specific things you’d probably want. Instead of creating my own, I just updated the existing one, correcting the errors and adding some good ones for our business. You can copy this list below, or adjust as you’d like, but here is the list I ended up with:

Oddly, the dropdown list is called ‘quote_term_dom’ if you are searching for it in the Dropdown Editor section of Studio..

ITEM NAME | DISPLAY LABEL

due_upon_receipt | Due upon receipt
due_upon_order | Due upon order placement
due_prior_ship | Due prior to shipping
due_upon_del_rec | Due upon receipt of delivery
due_ord_ship_date | Due on order ship date
net_7 | Net 7
net_14 | Net 14
net_30 | Net 30
net_60 | Net 60
blank | blank

See above for instructions on creating a blank field in a dropdown list

You can edit a dropdown list entry by clicking the pencil icon in the row, making the change, then clicking outside in some white space to mark the change as ready for deployment.

Save the changes with the Save button when complete.

I hope this post helped you get setup more quickly with SCRM.

Categories
Technology Tutorial Ubuntu

How to Recover Admin Access and Password from Digital Ocean WordPress Install

What happened: I thought I had saved my admin user and password safely in my password manager. Two weeks later after installing a WP instance, I realized I had not. Oops… Obviously the first thing I did was try the ‘reset password’ link on the /wp-login.php page. Oddly this failed. It would not send me an email, whether I used the username or the email (both were present in database, too, I confirmed).

My skills: Not very good. Limited to some very basic programming, but thankfully, I knew how to get inside MYSQL and roughly how that worked. If you are reading this you might need to get caught up on at least that much. There are lots of great tutorials and documentation on it and the syntax isn’t too crazy. Otherwise, you can try this tutorial and it might just work for you 🙂

This post is mainly to leave a quick workflow for the world who happens to have the exactly same setup and situation. You can adjust to your own situation too, as some of the MYSQL commands and WP stuff should be useful regardless of whether you are on the one-click Digital Ocean (“DO” from hereon in) droplet.

Special thanks to this page.

Key Specific info from Digital Ocean setup

The first thing I encountered when I realized my situation was that I didn’t have a mysql user / password as I normally would have if I manually set up my own server. Thankfully when you ssh into your DO server they have a helpful greeting page that tells you what’s up. It tells you this:

The MySQL root password and MySQL wordpress user password are saved
in /root/.digitalocean_password

It took me a really long time to try to figure out where this file is. Thankfully the ‘root’ part made me realize I likely had to be logged in as root user to do this. As such I ran sudo su, entered my password.

Then, it turned out as simple as cd /root.

Now you should be able to see the file when you run ls -all

Assuming you can see that, now you can just run nano .digitalocean_password to show the contents. It will show you two entries (at least it did for me) like this:

root_mysql_pass=”wildstringofrandomness”
wordpress_mysql_pass=”wildstringofrandomness”

Copy the second password (wordpress_mysql_pass) safely as that’s the one you’ll need for this.

The second thing you’ll need is the database name. After logging in to mysql you can run this command to see all databases on the server SHOW DATABASES; however I can save you that time by telling you the name of the database is:

  • DB NAME: wordpress

Working in MYSQL to Right Our Wrong

Assuming you now have your WP mysql password for the database and the database name, you can now log in to the database with this and enter your password when prompted:

mysql -u wordpress -p

The two fields we are working with are called:
user_login
user_pass

These three commands get you in to look around at all the user-related data tables:

USE wordpress;
SHOW TABLES;
DESCRIBE wp_users

Shows you the users:
SELECT user_login FROM wp_users;

Shows you the password (in MD5 encrypted form – effectively useless, by the way, see below…):
SELECT user_pass FROM wp_users;

Shows you ID of the users you are targeting. If you only have admin it will be ID 1:

SELECT ID, user_login FROM wp_users;

I learned (the long and hard way of course), that the password that is easily pulled with the commands above is encrypted with MD5 encryption meaning that you can’t just copy the password, go back to your WP login page, enter it, and enjoy your life. You have to reset it, using MD5 encryption again to encrypt your ‘normal’ password into the database. Good for security but an extra step for us. Consider it worth the pain I guess…

This next part assumes you have a current version of mysql. If you don’t, you’ll need to read the blog post way above and go the really long hard way…

To do the next part, you will need the ID of the user you are trying to reset the password for. This command I showed you from above will confirm for you:

SELECT ID, user_login FROM wp_users;

Now you can copy this template command I made for you below, paste it into a text editor (really bad idea to copy/paste/edit in your terminal as root!), update it with your new password, confirm the ID number and adjust accordingly (my number 1 is just an example so change accordingly), and then re-copy it for pasting back into your terminal:

UPDATE wp_users SET user_pass = MD5('insert_normal_password_here_between_apostrophes') WHERE ID = 1;

(Reminder – make sure you leave those apostrophes around your password!)
(Reminder – make sure your ID is correct!)

After running that command, you can run this next command to see that changes have happened. You’ll see another random MD5 thing for the password, but hopefully it is different from the one that was there before 🙂

SELECT ID, user_login, user_pass FROM wp_users;

You should now be able to go back to your WordPress /wp-login.php page and use your ‘normal_password’ with your old user name and get in.

Hope this saves someone much time and pain.

Categories
Business suitecrm Technology Tutorial Ubuntu

HOW TO MODIFY THE DISPLAY OF SUITECRM PRODUCT LINE ITEM ROWS IN QUOTE MODULE

It seems like I’m writing a series here on these SuiteCRM (‘SCRM’ moving forward) topics these days so I might as well keep going! If you haven’t read them, these might be of interest:

For this one, I will cover how to dig into the back end of SCRM to modify the way that the Quotes module displays the Line Items in their columns when not in edit mode. The content stuff will come in what I hope will be my last tutorial on this topic.

Disclaimer: I have no idea if any of these changes will survive a SCRM upgrade. Probably you’ll want to save any / all of your modified files somewhere safe when you create them, otherwise you’ll have to do a deep dive into how to do this properly (there is a correct way out there). In short, this is a hacky way to bring extra functionality until the GUI has what we need (hopefully soon, but they’re doing their best)

First, here is a reference link to the line_items.php file so that we are all on the same page and know to find it in our server and elsewhere.

This file is the one that tells SCRM how to lay out the Line Item module within the Quotes module. One would think you could just go in and edit the quotes module and a kind of a ‘sub-module’ for line items but it appears this functionality is still not here. If you are a good developer it would, obviously, be nice to have this built into the GUI so others don’t have to go through the pain of tutorials like these.

Let’s get familiar with the code blocks

For the purpose of this tutorial we will assume we all will be modifying products, not services and not groups, although I’m guessing you could apply the exact same method to those too.

There are two main code blocks in this page that concern most of what we’ll want to manipulate:

  1. This html table row (tr) block that starts on line 155. This one maps which column labels get applied to the headers and maps them.
  2. This second html table row block that starts on line 168

1. Headers and Column Display

This block, as you can see, assigns column widths to each row. I modified mine by adding two more, and doing some math on the column widths to adjust accordingly to hit 99% (which is where it was when I found it)

Then, I copied the following line of code from the example and pasted it right after where it was:

$product .= "<td width='9%' class='tabDetailViewDL' style='text-align: right;padding:2px;' scope='row'>".$mod_strings['LBL_VAT_AMT']."</td>";

The plan is to simply copy a line of what’s working, double it, and see if it shows up as a double. You can then modify stuff after you see it’s working (that’s my method). You can see that I modified the width a bit. You might want to try a more extreme number to see the results when the show up.

Then, I went into my terminal to add my changes in with the following steps:

  • Navigate to your Products_Quotes module directory:
    cd /var/www/html/suitecrm/modules/AOS_Products_Quotes
  • Open the file for editing: nano nano Line_Items.php
  • Drill down to the correct block. For me, I commented out the entire tr block with the php /** and */ comment lines so that I could just uncomment them, erase my code and have it back to normal again. Up to you. Once you find it, paste in the above line of code into the block.
  • Save your changes in your terminal (for me it is control x and save changes)

At this point, you will not see any changes in SCRM even if you refresh the browser. You need to perform these steps which I will then call ‘Repair / Rebuild’ after explaining them here:

  1. Go to ‘Admin’ in SCRM
  2. Go to Settings / Repair
  3. Select ‘Quick repair and rebuld’ option.
  4. Wait for changes
  5. Refresh browser to check changes

At this point you should see your column heading doubled, but there will be no content in the cell. That is because you need to do the next part which is to create the lines in the next code block

Mapping in the cell data to the cell

Now you should see your newly created header in the quotes module with line items.

Now we need to map the corressponding lines to that cell.

From my understanding there is one header per cell data and you have to map them in order. So if you wanted “Happy Tax” to be your fifth column / cell in the quote, you’d put it in the fifth position in for the header and then in this code block put it in the same position in the list. I just copied and pasted the same one, in the same posistion as my example above. This next one corresponds to the header I made above:

$product .= "<td class='tabDetailViewDF' style='text-align: right; padding:2px;'>".currency_format_number($line_item->vat_amt, $params)."</td>";

After adding this extra one, saving my changes, and doing the Repair / Rebuild, the data now showed up in the cell.

You have now successfully learned how to display the header and the cell content in the detail view of the line items in the Quotes module of SCRM. However, it’s still not useful since there is nothing mapping from the Products module. Hopefully that will be my next blog if everything goes well!

Hope that helps

Categories
Business suitecrm Technology Tutorial Ubuntu

HOW TO CHANGE THE ROW HEADERS IN SUITECRM LINE ITEMS IN QUOTES MODULE

PRE-CHAT

As always, SuiteCRM is one of my favourite business tools in the free and open software world. I like to describe it as ‘Sales Force on steroids’ because you can do whatever you want with it, basically, since the code is open and community supported. However, once in a while you will hit a road block.

This literally took me two weeks, full time, serious pain. Granted I didn’t know a drop of PHP, but wowzers – hard. The good news is this is going to save you that much time or more.

First of all, for some reason this really useful page evaded me for the first week. Had I found this everything would have made a lot more sense sooner. So bookmark this important page about SuiteCRM customizations. This page will be very useful if you plan to really dig deep and customize things for yourself and others.

This tutorial is assuming you have root access to your server and you are doing things ‘on the fly’ like me and not with a proper developers environment – a real weekend warrior hack space. If you are a real developer with skills, bonus! You can probably just upload your work and not worry about root user stuff maybe. In either case this will save you time.

Note this: SuiteCRM has periodic upgrades, of course, and if you do things the way they like your customizations will make it through the upgrade. Otherwise, you stand to lose your work when they upgrade. I would recommend documenting stuff as you go like I’m doing here in case you have to rebuild stuff. Ideally everything I’m doing here should be built right into the GUI, but for some reason it’s not for this part. Hopefully someone can take my work here and build this line item functionality right into the GUI.

WHAT I LEARNED ABOUT THE HEADERS

The customization of the row headers is essentially a ‘language-translation’ approach. This makes sense because if you were German you would want the word ‘List’ and ‘Price’ to be in German. However, unlike most of the other parts of SuiteCRM (‘scrm’ from now on) you can’t seem to edit these from within Admin / Studio – the logical place you would expect to be able to do this. I believe it is very rare that this kind of customization would be required however, more control over this part is, in my opinion, critical because of the various tax rates and other needs. In my case I needed to add recycling deposits and environmental fees to the row, but others I know needed multiple taxes.

In this case, we want to modify the strings / language that are found in this en_us language file.

Also it is worth mentioning that you should not change the pre-pending part of the php file as suiteCRM will go through and scan for that. So if you are using en_us (the default) make sure that stays at the front of your modified PHP file.

For this example, I want to change line 161 which has this:

‘LBL_UNIT_PRICE’ => ‘Sale Price’,

I don’t like the word ‘Sale Price’ and I want it to say ‘POOPY PRICE’ (to be sure it jumps off the page when it’s working)

Before we go forward, the documentation above fails to mention two important things:

  1. You must be root / sudo user in order to modify anything beyond the /modules path and
  2. There is no pre-existing ‘Language’ directory at all – you must create it first

This is the format and location of where your newly-created file will go and look like. Study it deeply:

custom/Extension/modules/<TheModule>/Ext/Language/<LanguageTag>.<Name>.php

Now let’s run the actual example step by step.

HOW TO DO IT.

As mentioned above, this string ‘Sale Price’ is found stock in this en_us language file in the AOS_Quotes module. So the first step is to be sure you are modifying the correct module. Adjust the paths according to your needs.

  1. Log into your SuiteCRM instance
  2. Change to root user (in my case with sudo su) and of course be careful since you can kill everything now, ha
  3. Navigate to the Ext folder: cd /var/www/html/suitecrm/custom/Extension/modules/AOS_Quotes/Ext/
  4. Make the ‘Language’ directory that SCRM needs: mkdir Language
  5. Navigate into it: cd Language
  6. Create a new blank php language customization file into which you will paste your code: sudo nano en_us.myTestFile.php
  7. Paste in this example code:
<?php
$mod_strings['LBL_UNIT_PRICE'] = 'SLOPPY PRICE';
  1. Control x to save your changes in the terminal (if you are using Ubuntu, if not not sure…)

At this point, in your test quote in SCRM you will see no changes it seems. I refreshed, I did a control + F5, I edited the quote, I did everything. My changes did not show. Then, I did the quick repair and build, refreshed changes and there was my new POOPY PRICE header. So these are those last steps after you make a customization:

  1. Go to ‘Admin’ in SCRM
  2. Under ‘System’ go to ‘Repair’
  3. Select ‘Quick Repair and Rebuild’
  4. Go back to your quote and refresh the page – your changes should now be visible in the header.

Very likely the process is the same for modifying all strings in SCRM so be sure to dig into that resource link above if you plan to go further.

I hope this helps and saves you the pain I had to go through! 🙂

Categories
Business suitecrm Technology Tutorial Ubuntu

How to Back Up your SuiteCRM Stuff on Ubuntu Server

Been a big fan and user of SuiteCRM for years. Never really did learn how to properly back up from my own server so yeah. Time to do it!

Backing up your SuiteCRM MYSQL Database

This is not for saving the files (ie. the custom settings you have made to SuiteCRM over the years and all the PDF templates, workflows, etc). This is just a raw datadump of the database. Be sure also to back up the suitecrm app files as a separate step (to be documented)

  1. ssh into the server with the usual ssh username@123.123.123.123
  2. cd to a location where you would like to back things up. I’ll just do the home directory for mine:
    cd ~
  3. Create a directory into which your backup will go. I will do example in home directory with directory name ‘suitecrm_backups’:
    mkdir suitecrm_backups
  4. CD into this new directory:
    cd suitecrm_backups
  5. Perform this command inserting the appropriate data:
    mysqldump -u admin_user -p suitecrm_DB_name > suitecrm_backup_yymmdd.sql

If you happen to forget the name of your database, you can log into mysql with your user/pw and use this command to show all databases. Login mysql -u admin_user -p and then show the databases with show databases;

  1. After the quality dump, look inside directory to make sure it’s all there and looking good:
    ls -al | grep suitecrm_backups
  2. Great! Now you’ll have to go and get that file off your server and you can skip to the ‘Retrieving Your Backed-up Files’ section below to do that now if you’d like.

Special thanks to this blog

Backing up your SuiteCRM Files

Now that you have your mysql database is backed up, create a file on your server where the soon-to-be backed-up SuiteCRM-specific files will go. It must be writable by the SuiteCRM user so I put mine right in the SuiteCRM folder in var/www/html/suitecrm’, although not sure if that’s a good idea. I’m just not smart enough to know but it did work. I’m pretty sure this folder would not make it through an upgrade, though, so we’d have to back up just before the upgrade and then re-create it after, I’m guesssing.

  1. Navigate to a good place: cd / var/www/html/suitecrm
  2. Make the backup directory: mkdir suite_backups
  3. Give directory correct permissions:
    sudo chown -R www-data:www-data /var/www/html/suitecrm/suite_backups
    sudo chmod -R 755 /var/www/html/suitecrm/suite_backups
  4. In the Suitecrm user interface, go to ‘Admin / Backups’
  5. Enter the path to the directory you just made in step 2 in the ‘directory’ field. Mine looks like this with the ‘var’: /var/www/html/suitecrm/suite_backups
  6. Enter the name of the file you want to call the zip file (ie. suitecrm_backup_yymmdd.zip) NOTE it seems that the system does not append the .zip so you have to make sure to manually enter it in this field.
  7. Confirm your settings. If it’s good you will be able to press ‘Run Backups’ button otherwise you’ll be told what is wrong.
  8. Press “Run Backups”
  9. If everything worked well it will tell you it was done correctly and sitting in the folder.
  10. Check to make sure it’s there with ls -al
  11. All good? Go ahead and download it using the cool sftp tool in the “Retrieving Your Backed-up Files” section below.

Retrieving Your Backed-up Files

  1. Open new terminal window on your local machine if you are like me and already logged into your suite machine in the original window above.
  2. In your new terminal window, navigate to where you want the backup files to end up. If you do nothing, they will end up in your HOme directory, but this is the one slightly weird thing to me. You can’t really change this later so do it now for simplicity, or at least note all your stuff will end up in your home directory.
  3. Log into the server in nearly identical way as ssh: sftp user@123.123.123.123 and enter password when prompted
  4. Navigate to your file using your familiar cd and ls commands. So easy. In fact, just like ubuntu terminal navigation…
  5. When you track down your desired file, do a get filename.zip and wait. You should see some ‘fetching’ comments and then it will end. Check to make sure you have it.

Hope this all helps. Thanks to the team at SuiteCRM.

Categories
Business Freedom and Privacy Nextcloud Technology Tutorial Ubuntu

Installing Nextcloud on Digital Ocean Ubuntu Server Droplet

Disclaimer: As always, my blogs are not supposed to be a well-written piece of technical literature but instead a better-than-crap version of a messy notepad. I hope it’s clear enough to help someone other than myself but I always check them to make sure at least I can understand it, ha.

It seems that there is a nice blog written and that Nextcloud (NC) is also a ‘snap’ to install on a server.

At some point in the process of learning this I assumed you had to install either NGINX or APACHE2 but, apparently it comes packaged with Apache and no one told me. So good news. Now you know. The other cool thing I learned is that it comes with its own LetsEncrypt easy-installer thing…

I noticed the blog starts by assuming you know how to create a sudo user and do your firewall stuff but let’s not assume that because probably there are others out there like me. Thankfully I’ve already written this for myself elsewhere so I’ll be able to paste those instructions right in this instructional as the first few “Big Steps”.

I will follow this nice blog

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. Make sure you already have a domain purchased and reserved for your needs. This is optional but I will assume you’re doing this for tutorial.
  2. Initiate your server / droplet
    I won’t give detailed instructions here because there is lots of documentation out there. I selected one with 2GB of ram (at time of writing it’s $10.00 uSD /month for this) only because the teacher recommended it. I didn’t research hardware specs and what I should do. Your needs may be different. I know using Nextcloud Talk uses a bit of RAM but not sure how much for a large conference.. worth investigating perhaps? I might also recommend calling your subdomain ‘nc’ instead of ‘files’ like I did in my example since you might do much more than ‘files’ with NC. “office.domain” or ‘nc.domain’ or ‘cloud.domain’ might make more sense?
  3. In your domain registrar, point your domain to your server’s name host. In my case it will be digital ocean’s which I will pull from the ‘networking’ section after adding the domain to Digital Ocean. In my case I already had a test domain setup, so what I did was set up a subdomain called “files.domain.com”. The reason you want to do this right away is because
  4. 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…). If you already have a DO space and SSH keys setup, you are already ready and can use those keys again.
  5. SSH into your new server
    ssh root@123.123.123.123

Note 1: Normally at this point when I install a server I do the usual sudo apt update and sudo apt upgrade but the main install script for Postal does this for you it seems.

But… you don’t have a sudo user yet so here you go:

Big Step 2 – Make a sudo (non-root super user) user

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 (you can name it what you’d like and don’t have to use ‘sysadmin’): 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
  • If this last part worked (and conveniently also set up your time stuff!) then you should be good to move forward with your new non-root user.

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…

From here, follow this blog again and make sure you follow his exact firewall rules. The SSH is already done but the rest seem to be an updated way of doing it, and when I was trying the older way I had nothing but headaches.

I would add these notes to go with the end of his blog where he is talking about checking the non-root user. This is how I had to think about it:

  • To be sure non-root user is working before logging out as root, open new terminal window (so both are open)
  • Try to log in with your new non-root user with ssh sysadmin@123.123.123.123
  • If successful, log out of your root user and continue and you can close the original root terminal window

Big Step 3 – Checking the Ports

Just before beginning the install of Nextcloud via snap, just take a minute to check your ports. I wasted the good part of a day over this.

Before moving on, take a moment to check your ports with a website like this and make sure at least 443 and 80 are open for all the domains you have set up for this box and also the IP address.

Big Step 4 – Follow the Nextcloud Install blog!

Thankfully the same author as the blog above also wrote a blog on how to install the Nextcloud snap. I tried other blogs but they were all dying and I think it’s because something has changed between ubuntu 18.04 and 20.04… not sure, but this nextcloud setup blog was the only one that worked for me.

Some of my notes to go with his great blog:

  • I liked the idea of using a command line to covertly create the user / pass for master admin account, rather than exposing that to the internet and hope no one lands there before you do. It shows that all you have to do is run this:

sudo nextcloud.manual-install <username> <password>
for example
sudo nextcloud.manual-install sammy password

However, when I ran it it hung and never finished:

sysadmin@files:/root$ sudo nextcloud.manual-install sammy password
>

Well, it turns out there must have been something ‘weird’ with the auto-generated password I had. It was loaded with special characters so perhaps one of those characters was not acceptable to the NC database? Not sure, but after I removed special characters from the password (not advised!) it worked fine with the syntax above.

Otherwise, you can go to the non-https web page and configure the admin account yourself via the gui.

Note this: Another way to deal with trusted_domains list

I would also add these notes to go with the ‘trusted_domains’ conversation in the blog. This was a bit new to me and caused me a few headaches over the last few weeks so I wanted to leave a record of ‘another way’ to deal with them.

I was greeted with this issue which i needed to solve.

The blog above has the very simple-looking command to add trusted domains to a list that will allow access to the nextcloud instance. The command is as follows:

sudo nextcloud.occ config:system:set trusted_domains 1 --value=example.com

What was not taught here is what’s going on though. the 1 is the array number that gets logged in a php file somewhere in Whoknowswhereville, USA, so for each one that you add (ie www, ip address, main domain, etc,) be sure to incremement it by one.

The defaul 0 will be ‘localhost’ so start with 1 and work up from there. Note also that you must have all the spaces verbatim. If you don’t have a space after the trusted_domains and after the 1, for example, you’ll have to sudo nano edit your mistake out, ha. So choose your poison. I find the sudo nano method below just as easy now that I know how to do it but I think the this one line command is great too if you are slow and steady.

Without further adoo, if you goof up a trusted_domain entry, you can manually edit the whole thing in the php array.

It took me a while, but I finally found it here:

cd /var/snap/nextcloud/current/nextcloud/config

The file is called ‘config.php’ and to edit it you can just do this and scroll down to the ‘trusted_domains’ array and type them in following the local host example:

sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php

After adding the trusted_domains, I was able to access my NC instance.

Big Step 5 – Secure up the traffic with LetsEncrypt!

Make sure your firewall stuff is done – hint.

Here’s a key lesson: this bad boy doesn’t work with ‘regular lets encrypt’ installation method so if you are in the habit of installing them, slow down and stop. This is the command for installing it with the NC snap:

sudo nextcloud.enable-https lets-encrypt

This was thanks to the blog

But before you actually run that command above, let’s revert back to our friend’s blog above and open up the necessary ports:

sudo ufw allow 80,443/tcp

now go ahead and run the let’s encrypt command above and follow along in the blog to make sure you’re doing it right.

Did you get a failed letsencrypt attempt like I did one time? With a message like this?

To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.

If so, you probably have a closed port. See my warnings above.

Big Step 6 – Enjoy

Probably there are some great blogs out there for actually using NC but at least now you can go to your domain and get started.

Have a nice day!

Categories
Nextcloud Technology Tutorial

Fixing My Dead Nextcloudpi box in three simple steps

My nextcloudpi box was kicking back errors and wouldn’t start. It was in a degraded state. I then learned about systemctl --failed command which showed something wrong with certbot. Thankfully I already knew that was related to LetsEncrypt.

I realized that it was trying to renew two domains that weren’t there and were expired and would be unable to renew anyway even if they tried so… not sure why they were there in the first place other than perhaps some testing I did a long time ago? So I wanted to remove them completely to rule them out so here are the instructions for anyone else trying the same thing on Nextcloudpi or another server with ‘random letsencrypt domains’

Part 1 – Removing Random LetsEncrypt Domains and Certificates

Should be as simple as running these commands and replacing yourdomain.com with your domain verbatim.

  1. sudo rm -rf /etc/letsencrypt/archive/yourdomain.com
  2. sudo rm -rf /etc/letsencrypt/live/yourdomain.com
  3. sudo rm -rf /etc/letsencrypt/renewal/yourdomain.com.conf

Part 2 – Disabling the Deleted Site from Apache’s Reach

After doing Part 1 above and removing these random domains that should not have been there I ran sudo systemctl restart certbot.service to restart the certbot service. This seemed to work now. However, when I ran sudo systemctl status it still did not show a green light.

After digging deeper by running a sudo journalctl -xe command the log showed here was a syntax error in /etc/apache2/sites-enabled/000-default.conf. After going to line 43 I realized that it was trying to run one of the domains I had deleted in Part 1 above. Thankfully I already knew how to enable and disable apache sites.

to do that I did:

sudo a2dissite 000-default.conf

Then I did a:

sudo systemctl restart apache2.service

Then I did another check on services:

sudo systemctl status

Nice, the apache stuff now seems fixed but…

Part 3 – Fixing some Wifi-Country.service Error Thing

I still have another error which the system seems not willing to go around! Why? Why me? haha

wifi-country.service loaded failed failed Disable WiFi if country not set

So then I found this blog where i pasted the following to the bottom of the file

country=CA
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="testing"
psk="testingPassword"

Full disclaimer: I have absolutely no idea what this stuff above does, so yeah – copy and paste at your own risk like I did!

There weren’t any instructions to restart a service which I expected. And, as expect, it was still dead. Thankfully my guess was correct and there should have been a service restart command as follows:

sudo systemctl restart wifi-country.service

That seemed to work…

Then I ran sudo systemctl status and everything looked running. Yay!

Then BOOM! System back. Nextcloudpi started syncing again.

I have no idea why things went bad but it’s a good day when you can fix it indeed! Usually doesn’t go this well for me but I guess I”m learning a few things so let’s keep suffering for growth shall we?

Have a good day!

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.