|
| 1 | +## Building Brilliant (home to 'allApp.py' and others) |
| 2 | + |
| 3 | +(alternate notes in OneNote) |
| 4 | + |
| 5 | +**Assumptions:** Things that were already in place. |
| 6 | + |
| 7 | +- In all cases, the OS is Ubuntu. |
| 8 | +- Brilliant is the name of the machine I'm working on. I'm replacing the storage drive and updating the OS. |
| 9 | +- Valiant is the name of the machine I am working at. Windows Subsystem for Linux running Ubuntu. |
| 10 | +- Brilliant is in the 'hosts' file on Valiant, so I don't need to type the IP address. |
| 11 | +- ssh keys are in place on Valiant for use in public key authentication (passwordless login). |
| 12 | +- mySQL databases must be moved from the old drive to the new one. They must be 'exported' before the old drive is deactivated. |
| 13 | +- The username for the primary user must be the same on the new drive/OS as on the old one. |
| 14 | +- The contents of the /home/{user}/ folder must be copied intact to the new drive. That's where my Python program files live. |
| 15 | + |
| 16 | + |
| 17 | +Curly brackets should not be typed in commands. They indicate a private value that should be known only to you. |
| 18 | +For example: {user} is your username. |
| 19 | + |
| 20 | +## Getting Started ## |
| 21 | + |
| 22 | +### First: Before removing the old drive, prepare to move mySQL data. |
| 23 | + |
| 24 | +**Either ssh into Brilliant, or do this locally on Brilliant** |
| 25 | + |
| 26 | + mysql -u {user} -p |
| 27 | + |
| 28 | +Now you're logged into mySQL, so from now on we're at the mySQL prompt. |
| 29 | + |
| 30 | + select @@datadir; |
| 31 | + show databases; |
| 32 | + quit; |
| 33 | +This gives you info on the location and names of your databases. |
| 34 | + |
| 35 | +**Now export your databases** at the Linux commandline. |
| 36 | + |
| 37 | + mysqldump outdata > outdata-20210220.sql -u {user} -p |
| 38 | + |
| 39 | +The result is 'outdata-20210220.sql' in your current directory. |
| 40 | +Repeat for each database you want to export / backup. |
| 41 | + |
| 42 | +### Second: Install the new drive. |
| 43 | + |
| 44 | +**Locally on Brilliant:** |
| 45 | +Prepare the new drive. |
| 46 | + a. Disconnect the old drive from the computer. |
| 47 | + b. Connect the new drive. |
| 48 | + c. Install the OS (Remember the user name and the machine name need to be the same as they were before.) |
| 49 | + |
| 50 | +Get ssh-server up and running on the new drive. |
| 51 | + |
| 52 | + sudo install ssh-server |
| 53 | + sudo nano /etc/sshd_config |
| 54 | + |
| 55 | +Uncomment #port 22 and replace 22 with your {port} number. |
| 56 | + |
| 57 | + sudo service sshd restart |
| 58 | + |
| 59 | +**Make the old drive available to the system in some fashion.** |
| 60 | + |
| 61 | +I used a USB interface to connect the old drive to Brilliant. |
| 62 | +Then copy these folders over to the new drive: |
| 63 | + |
| 64 | + The /home/{user}/all folder. |
| 65 | + The /home/{user}/.ssh folder. |
| 66 | + |
| 67 | + |
| 68 | +**Get mySQL up and running on the new drive.** |
| 69 | + |
| 70 | + sudo apt install mysql-server |
| 71 | + sudo mysql (logs you in as root) |
| 72 | + create user {user}@localhost identified by '{password}'; |
| 73 | + grant all privileges on *.* to {user}@localhost; |
| 74 | + flush privileges; |
| 75 | + quit; |
| 76 | + |
| 77 | +That should have done it. But NO, I had been using 5.7.33 and the new mySQL was 8.0.23. |
| 78 | +Every time I brought my databases in, mysql went squirrely. |
| 79 | + |
| 80 | +I finally had to figure out how to install 5.7.3 again. It went like this: |
| 81 | + |
| 82 | + wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb |
| 83 | + sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb |
| 84 | + Select Bionic |
| 85 | + Select mySQL 5.7 server |
| 86 | + sudo apt-get update |
| 87 | + sudo apt install -f mysql-client=5.7.33-1ubuntu18.04 |
| 88 | + sudo apt install -f mysql-community-server=5.7.33-1ubuntu18.04 |
| 89 | + sudo apt install -f mysql-server=5.7.33-1ubuntu18.04 |
| 90 | + |
| 91 | +I did assign a password to the 'root' account. I tried to use the 'empty' method first time through these steps, but it didn't work, so I had to start over. |
| 92 | + |
| 93 | + sudo mysql_secure_installation |
| 94 | + |
| 95 | + sudo ufw status verbose |
| 96 | + sudo ufw allow {port}/tcp |
| 97 | + sudo ufw allow from 192.168.1.1/24 to any port 3306 |
| 98 | + sudo ufw allow 80,443/tcp |
| 99 | + |
| 100 | + sudo ufw enable |
| 101 | + |
| 102 | +**Create a mySQL user for each node of PiNet for allSysReport.service (zAllSysChk.py)** |
| 103 | + |
| 104 | +**ssh-copy-id -i id_rsa -p {port} {user}@{machine}** |
| 105 | + |
| 106 | +This needs to be done from Brilliant (/home/{user}/.ssh) to every other PiNet machine <b> including Brilliant </b>. I know, that doesn't exactly make sense, but it is true. |
| 107 | + |
| 108 | + |
| 109 | +**Locally on Valiant** |
| 110 | + |
| 111 | +Copy the ssh keys to Brilliant and reset known_hosts to accept the new Brilliant. |
| 112 | + |
| 113 | + ssh-copy-id -i {publickeyfile} -p{port} {user}@brilliant |
| 114 | + ssh-keygen -f "/home/{user}/.ssh/known_hosts" -R "[brilliant]:{port}" |
| 115 | + |
| 116 | +**Log into Brilliant.** |
| 117 | + |
| 118 | + ssh -p {port} |
| 119 | + |
| 120 | +Start installing some of the dependencies. |
| 121 | + |
| 122 | + sudo apt install python3-pip |
| 123 | + sudo apt-get install nginx |
| 124 | + sudo pip3 install gunicorn |
| 125 | + pip3 install mysql-connector |
| 126 | + sudo apt-get install python3-numpy |
| 127 | + pip3 install noaa-sdk |
| 128 | + sudo pip3 install -U Flask |
| 129 | + sudo pip3 install flask_wtf |
| 130 | + pip install pyyaml ua-parser user-agents |
| 131 | + sudo apt install mailutils |
| 132 | + sudo apt-get install msmtp msmtp-mta |
| 133 | + |
| 134 | +**Configure nginx** |
| 135 | + |
| 136 | + sudo nano /etc/nginx/nginx.conf |
| 137 | + |
| 138 | +Once in there, look for these various entries and make them look like this, character for character, no # in front: (All this comes from e-tinkers linked above.) |
| 139 | + |
| 140 | + multi_accept on; |
| 141 | + keepalive_timeout 30; |
| 142 | + server_tokens off; |
| 143 | + gzip_vary on; |
| 144 | + gzip_proxied any; |
| 145 | + gzip_comp_level 5; |
| 146 | + gzip_http_version 1.1; |
| 147 | + |
| 148 | +Add a line just before the <b>gzip_types</b> line that says this: |
| 149 | + |
| 150 | + gzip_min_length 256; |
| 151 | + |
| 152 | +Honestly, I don't know if this is necessary, but it was in the instructions, and I can say it didn't hurt anything, so, plug this in just below the # gzip_types ... line that is there. (Yes, you can just use this to replace the existing line.) |
| 153 | + |
| 154 | + gzip_types |
| 155 | + application/atom+xml |
| 156 | + application/javascript |
| 157 | + application/json |
| 158 | + application/rss+xml |
| 159 | + application/vnd.ms-fontobject |
| 160 | + application/x-font-ttf |
| 161 | + application/x-web-app-manifest+json |
| 162 | + application/xhtml+xml |
| 163 | + application/xml |
| 164 | + font/opentype |
| 165 | + image/svg+xml |
| 166 | + image/x-icon |
| 167 | + text/css |
| 168 | + text/plain |
| 169 | + text/x-component |
| 170 | + text/javascript |
| 171 | + text/xml; |
| 172 | + |
| 173 | +**Set up msmtp to handle notifications** |
| 174 | + |
| 175 | +The instructions can be found in the doorPi (ohd) docs here on Github. https://github.com/casspop/ohd/blob/master/SetupRaspianForOhd.md |
| 176 | +I don't see any reason to copy and paste that over here. |
| 177 | + |
| 178 | + |
| 179 | + |
0 commit comments