Home systems: Difference between revisions

From SoftwareGuy
Jump to navigation Jump to search
Mark (talk | contribs)
Mark (talk | contribs)
 
(3 intermediate revisions by the same user not shown)
Line 157: Line 157:


http://www.raspberrypi.org/forums/viewtopic.php?&t=27035
http://www.raspberrypi.org/forums/viewtopic.php?&t=27035
== Raspberry pi mount usb stick ==
sudo mkdir /temp
sudo mount /dev/sda1 /temp  -o uid=pi,gid=pi
== Raspberry pi gpio ==
Command line:
pinctrl help
pinctrl get 26
pinctrl set 26 ip pu
pinctrl get 26
Python:
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(pin.findValueInt("Inject"), GPIO.OUT)
GPIO.output(pin.findValueInt("Inject"), initialState)
GPIO.setup(pin.findValueInt("Button"), GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.output(p, GPIO.LOW)
GPIO.output(p, GPIO.HIGH)
b = GPIO.input(pin.findValueInt("Button"))


== Backing up the server ==
== Backing up the server ==
Line 186: Line 211:


----
----
== Nextcloud backup info ==
How to backup your instance
Kyle Fazzari edited this page on Aug 7, 2019 · 7 revisions
The nextcloud snap includes an utility to backup and restore your instance. Right now it can export:
* The apps
* The database
* The config
* The raw data
*
* But note that this does not cover exporting other settings, like HTTPS certificates.
Export everything
Run <code>sudo nextcloud.export</code> and it'll turn on maintenance mode and dump a backup of your entire instance into a timestamped folder, something like 20190121-153921, inside <code>/var/snap/nextcloud/common/backups/</code>.
After the export is complete the snap will forget about it, so feel free to do whatever you like with it; one option could be to tar it, with a command like this:
<code>sudo tar -cvf 20190121-153921_nextcloud-backup.tar /var/snap/nextcloud/common/backups/20190121-153921</code>
Import everything
You can import an exported backup by running <code>sudo nextcloud.import path/to/backup/dir</code>.
Important! Importing a backup will completely blow away the current instance: it'll drop the database, delete the installed apps, and delete all raw data, replacing each with that from the backup.
The only constraints are that:
This path needs to be available from confinement, so put it in /var/snap/nextcloud/common or /var/snap/nextcloud/current/ somewhere.
User root needs to be the owner.
So continuing with the previous example, these two commands would need to be executed before importing:
<code>sudo mv 20190121-153921_nextcloud-backup.tar /var/snap/nextcloud/current/</code>
<code>sudo chown -R root:root /var/snap/nextcloud/current/20190121-153921/</code>
Selective backup
Note that you can limit what is exported (and what is imported) with arguments that are documented if you run nextcloud.export -h or nextcloud.import -h.
Example
Usage:
    nextcloud.export [OPTIONS]
    Export data suitable for migrating servers. By default this
    includes the Nextcloud database, configuration, and data
    (equivalent to running nextcloud.export -abcd).
Available options:
    -h: Display this help message
    -a: Include the (non-default) apps
    -b: Include the database
    -c: Include the config
    -d: Include the data (can be quite large)
Tips & tricks
Q. Can exporting specify the data directory?
A. Not directly, but you should be able to use a symlink. For example, creating a symlink from the data directory to /var/snap/nextcloud/common/nextcloud/data
Q. Can I somehow export/import my HTTPS certs?
A. Yes, everything related to them is stored in the /var/snap/nextcloud/current/certs directory, so copying it and preserving its permissions and owner works.
Caveats
The export/import tools are mostly written from the perspective of wanting to migrate your current install to another instance of the snap. Keep that in mind:
It won't be particularly helpful in migrating to the snap from a non-snap install
Likewise, it won't be particularly helpful in migrating away from the snap
It creates a copy of your config, trusted domains and all. If you're migrating to a new domain name, keep this in mind-- you'll need to update the trusted domains yourself.
[[Main_Page]] Main
[[Main_Page]] Main

Latest revision as of 14:47, 10 May 2024

This doc contains the things I've found I need to update to get my linux2 server working.

Changing default serial port protections[edit | edit source]

create a file, such as <code>99-local.rules</code> in the following directory: <code>/etc/udev/rules.d/</code> with the following info:

<pre>

  1. Give world read/write access to ttyS* and ttyUSB* serial devices

KERNEL=="tty[A-Z]*", GROUP="uucp", MODE="0666" </pre>

Ubuntu dual monitors[edit | edit source]

Run <code>nvidia-settings</code>. Now we may need to modify the Xconf file, if so see the following:

  1. Open nvidia-settings by searching for nvidia in the Dash, or run the command gksudo nvidia-settings in the Terminal. Note not to press the apply button.
  2. Under 'Xserver Display Configuration' select TwinView and configure the settings for the monitors to your liking.
  3. Click 'Save to X Configuration File' and an error message should appear. Click OK.
  4. In the next dialog box click the button to 'Show Preview'.
  5. Leave the preview window open and open a Terminal. Run the following commands in the Terminal to back up your xorg.conf file and open the original file in a test editor. If something goes wrong, just revert to your backed up xorg.conf.
  6. sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
  7. gksudo gedit /etc/X11/xorg.conf`
  8. Copy the text from the nvidia-settings preview window into the xorg.conf file. Save the xorg.conf file and close gedit. Click 'Cancel' to close the nvidia-settings preview window. Then click 'Quit' to exit completely out of nvidia-settings without applying or saving any data.
  9. Restart your computer. If all went well, the two monitors should work together.

Note: As of ubuntu 12.04 you don't appear to need to copy the xorg.conf files around. Just clicking save is all it takes.

Rebuilding Raid[edit | edit source]

Rebuilding a raid system?

Detail from mdadm of good working file system prior to zeroing the superblock.

<pre> sudo mdadm --detail /dev/md4 /dev/md4:

       Version : 0.90
 Creation Time : Sat Mar 19 08:02:27 2011
    Raid Level : raid6
    Array Size : 160649856 (153.21 GiB 164.51 GB)
 Used Dev Size : 80324928 (76.60 GiB 82.25 GB)
  Raid Devices : 4
 Total Devices : 4

Preferred Minor : 4

   Persistence : Superblock is persistent
   Update Time : Sun Jun  3 21:06:27 2012
         State : clean 
Active Devices : 4

Working Devices : 4

Failed Devices : 0
 Spare Devices : 0
        Layout : left-symmetric
    Chunk Size : 64K
          UUID : b60f9401:efa1275e:6caba8f0:d8b2a7d7
        Events : 0.457
   Number   Major   Minor   RaidDevice State
      0       8       66        0      active sync   /dev/sde2
      1       8       82        1      active sync   /dev/sdf2
      2       8       98        2      active sync   /dev/sdg2
      3       8       50        3      active sync   /dev/sdd2

</pre>

Note, the drive order is very important. Also, remove the ARRAY entry from /etc/mdadm/mdadm.conf for the drive.

<pre> sudo mdadm --stop /dev/md6 sudo mdadm --zero-superblock /dev/sd[defg]2 sudo mdadm --create /dev/md6 --metadata=1.0 --chunk=64 --level=6 --raid-devices=4 /dev/sde2 /dev/sdf2 /dev/sdg2 /dev/sdd2 </pre>

Ok, now we need to get the blkid from the md filesystem and add an entry into the mdadm.conf file which matches.

<pre> sudo blkid /dev/md6 # edit mdadm.conf file and add entry "ARRAY /dev/md6 UUID=dad67a5c:0907045c:7eb49ca0:d0f6f000" sudo mdadm --assemble /dev/md6 --update=resync sudo mdadm --detail /dev/md6 sudo blkid /dev/md6 sudo mount -t ext3 /dev/md6 /mnt/temp

watch -n 1 cat /proc/mdstat </pre>

or... ???

<pre> sudo mdadm --stop /dev/md6 sudo mdadm --zero-superblock /dev/sd[defg]2 sudo mdadm --create /dev/md6 --metadata=0.9 --chunk=64 --level=6 --raid-devices=4 /dev/sde2 /dev/sdf2 /dev/sdg2 /dev/sdd2 sudo mdadm --assemble /dev/md6 --update=resync sudo mdadm --detail /dev/md6 sudo blkid /dev/md6 sudo mount -t ext3 /dev/md6 /mnt/temp </pre>

If this is a new raid drive, make the filesystem then mount

<pre> sudo mkfs /dev/md6 sudo mount /dev/md6 /mnt/temp </pre>

Fixing mail permission errors on linux2[edit | edit source]

Do the following: <pre> sudo touch /var/mail/$USER sudo chown $USER:mail /var/mail/$USER sudo chmod o-r /var/mail/$USER sudo chmod g+rw /var/mail/$USER </pre>

Updates to tzo configuration[edit | edit source]

After installing tzo I needed to update the <code>tzod</code> script in <code>/etc/init.d</code>. I updated the following script segment to look like this (basically just added the lines with <code>/lib/lsb...</code>: <pre> if [ -f /etc/rc.d/init.d/functions ]; then

       . /etc/rc.d/init.d/functions

elif [ -f /etc/init.d/functions ] ; then

       . /etc/init.d/functions

elif [ -f /lib/lsb/init-functions ] ; then

   . /lib/lsb/init-functions

else </pre>

Next I added a soft link in the <code>/etc/rc.5.d/</code> directory: <pre> sudo ln -s ../init.d/tzod S99tzod </pre>


Trick for port forwarding[edit | edit source]

This lets me access the CUPS system on the linux2 server from my linux laptop. Issue this command on the laptop, insert the appropriate passwords...

<pre> ssh -L 6310:localhost:631 root@remote_ip_address </pre>

Now access the cups system via the browser on the laptop by going to <code>localhost:6310</code>.


Making movies from jpg files[edit | edit source]

This seems to work...

<pre> mencoder -ovc copy -mf w=320:h=240:fps=12:type=jpg "mf://*.jpg" -o output.avi mencoder -ovc copy -mf w=320:h=240:fps=12:type=jpg "mf://@list.txt" -o output.avi </pre>

Raspberry pi serial port[edit | edit source]

http://www.raspberrypi.org/forums/viewtopic.php?&t=27035

Raspberry pi mount usb stick[edit | edit source]

sudo mkdir /temp
sudo mount /dev/sda1 /temp  -o uid=pi,gid=pi

Raspberry pi gpio[edit | edit source]

Command line:

pinctrl help
pinctrl get 26
pinctrl set 26 ip pu
pinctrl get 26

Python:

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(pin.findValueInt("Inject"), GPIO.OUT)
GPIO.output(pin.findValueInt("Inject"), initialState)
GPIO.setup(pin.findValueInt("Button"), GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.output(p, GPIO.LOW)
GPIO.output(p, GPIO.HIGH)
b = GPIO.input(pin.findValueInt("Button"))

Backing up the server[edit | edit source]

Run the following command on the desktop which has the backup disk mounted. This will backup /home to the backup drive, and this command should be repeated for each filesystem on linux server. rsync is now enabled on the msgsb.com server.

rsync -avzH linux2:/home2 /media/mhamilton/Seagate\ Backup\ Plus\ Drive/home2/

Also this can be run on the pi at the condo. Login to the condo pi and run the following commands:

ssh pi@h-condo.dyndns.org
rsync -avzh mhamilton@msgsb.com:/home3 /backup-msgsb/home3

To setup ssh to not query for passwords, from the pi:

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub mhamilton@msgsb.com

Latest sshd configuration changes as of ubuntu 22.04.03 lts[edit | edit source]

In /etc/ssh/sshd_config change the following lines as shown:

PubkeyAuthentication yes

PubkeyAcceptedKeyTypes=+ssh-rsa

Then restart sshd

sudo systemctl restart sshd


Nextcloud backup info[edit | edit source]

How to backup your instance Kyle Fazzari edited this page on Aug 7, 2019 · 7 revisions

The nextcloud snap includes an utility to backup and restore your instance. Right now it can export:

  • The apps
  • The database
  • The config
  • The raw data
  • But note that this does not cover exporting other settings, like HTTPS certificates.

Export everything

Run sudo nextcloud.export and it'll turn on maintenance mode and dump a backup of your entire instance into a timestamped folder, something like 20190121-153921, inside /var/snap/nextcloud/common/backups/.

After the export is complete the snap will forget about it, so feel free to do whatever you like with it; one option could be to tar it, with a command like this:

sudo tar -cvf 20190121-153921_nextcloud-backup.tar /var/snap/nextcloud/common/backups/20190121-153921

Import everything

You can import an exported backup by running sudo nextcloud.import path/to/backup/dir.

Important! Importing a backup will completely blow away the current instance: it'll drop the database, delete the installed apps, and delete all raw data, replacing each with that from the backup.

The only constraints are that:

This path needs to be available from confinement, so put it in /var/snap/nextcloud/common or /var/snap/nextcloud/current/ somewhere.

User root needs to be the owner.

So continuing with the previous example, these two commands would need to be executed before importing:

sudo mv 20190121-153921_nextcloud-backup.tar /var/snap/nextcloud/current/

sudo chown -R root:root /var/snap/nextcloud/current/20190121-153921/

Selective backup

Note that you can limit what is exported (and what is imported) with arguments that are documented if you run nextcloud.export -h or nextcloud.import -h.

Example

Usage:

   nextcloud.export [OPTIONS]
   Export data suitable for migrating servers. By default this
   includes the Nextcloud database, configuration, and data
   (equivalent to running nextcloud.export -abcd).

Available options:

   -h: Display this help message
   -a: Include the (non-default) apps
   -b: Include the database
   -c: Include the config
   -d: Include the data (can be quite large)

Tips & tricks

Q. Can exporting specify the data directory?

A. Not directly, but you should be able to use a symlink. For example, creating a symlink from the data directory to /var/snap/nextcloud/common/nextcloud/data

Q. Can I somehow export/import my HTTPS certs?

A. Yes, everything related to them is stored in the /var/snap/nextcloud/current/certs directory, so copying it and preserving its permissions and owner works.

Caveats

The export/import tools are mostly written from the perspective of wanting to migrate your current install to another instance of the snap. Keep that in mind:

It won't be particularly helpful in migrating to the snap from a non-snap install

Likewise, it won't be particularly helpful in migrating away from the snap

It creates a copy of your config, trusted domains and all. If you're migrating to a new domain name, keep this in mind-- you'll need to update the trusted domains yourself.


Main_Page Main