[Quick Links] |
Search Site

Site Details

rendered in 0.0685 secs

Captain's Log | Monday 14th of August 2017

How do I add a user to sudo group?su
enter root password when prompted
visudo
...
# User privilege specification
root    ALL=(ALL:ALL) ALL

userNameToAdd ALL=(ALL) ALL
:wq
service sudo restart
exit
.. test it
How can I get a basic stack up in debian?sudo apt-get install aptitude
sudo aptitude install ~pstandard ~pimportant ~prequired
How can I make sure my debian terminal is giving me full colour (color) support with vim?vim .bashrc
...
export TERM=xterm-256color
:wq

sudo apt-get install vim-gnome

vim ~/.vimrc
...
:syntax enable
:wq
Can I mount a share over SSH?sudo apt-get install sshfs
sudo mkdir /mnt/daniel    local path we're going to use for remote mount
sudo chown $USER:$USER daniel   now I mention this step at it's completely useless but I want you to see why
ls -lah
total 20K
drwxr-xr-x  5 root    root    4.0K Jun 24 06:54 .
drwxr-xr-x 25 root    root    4.0K Mar  5 10:02 ..
drwxr-xr-x  3 root    root    4.0K Mar  5 09:52 boot-sav
drwxr-xr-x 10 rick111 rick111 4.0K Jun 23 04:33 sophie
drwxr-xr-x  2 rick111 rick111 4.0K Jun 24 06:54 daniel

sudo sshfs -o allow_other -p1337 rick111@117.34.196.38:/ /mnt/daniel/  -p1337 use port 1337 of remote ssh server
ls -lah
total 20K
drwxr-xr-x  5 root    root    4.0K Jun 24 06:54 .
drwxr-xr-x 25 root    root    4.0K Mar  5 10:02 ..
drwxr-xr-x  3 root    root    4.0K Mar  5 09:52 boot-sav
drwxr-xr-x 10 rick111 rick111 4.0K Jun 23 04:33 sophie
drwxr-xr-x  1 root    root    4.0K Jun 19 18:53 daneil

Okay, take a peek. Permission of the folder has been changed to root, probably because we made it under /mnt/ rather than /home/dave/media/ but whatever. If you use the "-o allow other" option as we did you can still access the mount, if you had missed out that option you would just see a load of "????????????" question marks when you run ls -lah against the /mnt/ for that folder name and would be unable to access anything within.

Can I auto mount this at boot?
probably. i've not got round to that yet as ssh-cop-id doesn't seem to apply for the auto connect of sshfs and I also need to usual a different port from usual and stuff so.

to unmount
sudo umount /mnt/daniel
Book review: Smalltalk Best Practice Patterns
Not for me. I enjoy it more when the philosophy behind methods are the discussed at detail and then the occasional code snippet to solidify the example. A lot of spam code which isn't a bad thing in general it all just comes down to how you learn best, and for me I like to hear the reasoning behind the numbers, rather than the equations.
What's the difference between CTRL + Z and CTRL + C to end a process?
CTRL+Z pauses a job
CTRL+C terminates a job
Here is an example of pausing a job and then resuming it.
sudo tail -f /var/log/maillog
CTRL + Z
  [2]+  Stopped                 sudo tail -f /var/log/maillog
jobs
  [1]-  Stopped                 sudo tail -f /var/log/maillog
  [2]+  Stopped                 sudo tail -f /var/log/messages

fg %2   (switch back and resume job2)
  sudo tail -f /var/log/maillog
  Jun  8 16:02:32 mail dovecot: imap-login: Login: user= ...blah
  Jun  8 16:02:32 mail dovecot: imap-login: Login: user= ...blah
  Jun  8 16:02:32 mail dovecot: imap-login: Login: user= ...blah
  Jun  8 16:02:32 mail dovecot: imap-login: Login: user= ...blah
  Jun  8 16:03:34 mail postfix/anvil[20343]: statistics: max connection rate 1/60s  ...blah
  Jun  8 16:03:34 mail postfix/anvil[20343]: statistics: max connection count 1 for  ...blah
  Jun  8 16:03:34 mail postfix/anvil[20343]: statistics: max cache size 1 at  ...blah

  You can also start a job in the background by adding & to the end of your command. The job will start in the background and output progress but you can still type whatever into bash


Captain's Log | Monday 14th of August 2017

I've setup an nfs share and everything looks correct but it just won't mount!


If you've only just installed the "apt-get install nfs-kernel-server nfs-common", configured /etc/exports and restarted the service let me stop you right there. You need to reboot your server to get the cogs in motion for the first time after installing the tools. Sorry.

Whilst talking of mounts, how do I browse mounts on a server and then..... erm, mount one?


make sure you've got sudo apt-get install nfs-common
showmount -e  192.168.0.9
    if it returns 'clnt_create: RPC: Program not registered', make sure you've rebooted the host running nfs after the initial installation/setup of nfs
Export list for 192.168.0.9:
/mnt/1tb/Downloads 192.168.0.0/24

sudo mkdir /mnt/sophie  local path we're going to use for remote mount
sudo mount 192.168.0.9:/mnt/1tb/Downloads /mnt/sophie

You've done all the hard work now, make sure you add an entry in fstab so it mounts after reboot.
sudo vim /etc/fstab
+192.168.0.9:/mnt/1tb/Downloads /mnt/sophie nfs defaults 0 0
:wq

bounce your box and make sure it all works as expected.


Captain's Log | Monday 14th of August 2017

Windows Server Reboots

server_reboots.bat
@echo off
echo You're about to start rebooting all of the servers,
echo please close this script if opened in error.
echo.
echo shutdown -a will abort the shutdown
echo.
echo.
echo.
echo Automatic reboot process will begin in 15 seconds
echo.
echo.
timeout 15
echo.
echo.
shutdown /m \\SRV-DC1 /r /f /t 60 /d p:1:1
shutdown /m \\SRV-LEO1 /r /f /t 60 /d p:1:1
shutdown /m \\SRV-LEO2 /r /f /t 60 /d p:1:1
shutdown /m \\SRV-WA /r /f /t 60 /d p:1:1
echo.
echo.
echo waiting 5 minutes to continue
timeout 600
shutdown /m \\SRV-DC2 /r /f /t 60 /d p:1:1
shutdown /m \\SRV-MAN1 /r /f /t 60 /d p:1:1
shutdown /m \\SRV-MAN2 /r /f /t 60 /d p:1:1

echo.
echo.
echo waiting 5 minutes to continue
timeout 600
shutdown /m \\SRVDB /r /f /t 60 /d p:1:1
shutdown /m \\SRV-FS /r /f /t 60 /d p:1:1
shutdown /m \\SRVMAN1 /r /f /t 60 /d p:1:1
shutdown /m \\SRVGW1 /r /f /t 60 /d p:1:1
echo.
echo.
echo.
echo script complete
Get-Uptime.ps1
<#
.SYNOPSIS
Get-Uptime retrieves boot up information from a Aomputer.
.DESCRIPTION
Get-Uptime uses WMI to retrieve the Win32_OperatingSystem
LastBootuptime property. It displays the start up time
as well as the uptime.

Created By: Jason Wasser @wasserja
Modified: 8/13/2015 01:59:53 PM  
Version 1.4

Changelog:
* Added Credential parameter
* Changed to property hash table splat method
* Converted to function to be added to a module.

.PARAMETER ComputerName
The Computer name to query. Default: Localhost.
.EXAMPLE
Get-Uptime -ComputerName SERVER-R2
Gets the uptime from SERVER-R2
.EXAMPLE
Get-Uptime -ComputerName (Get-Content C:\Temp\Computerlist.txt)
Gets the uptime from a list of computers in c:\Temp\Computerlist.txt.
.EXAMPLE
Get-Uptime -ComputerName SERVER04 -Credential domain\serveradmin
Gets the uptime from SERVER04 using alternate credentials.
#>
Function Get-Uptime {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$false,
                        Position=0,
                        ValueFromPipeline=$true,
                        ValueFromPipelineByPropertyName=$true)]
        [Alias("Name")]
        [string[]]$ComputerName=$env:COMPUTERNAME,
        $Credential = [System.Management.Automation.PSCredential]::Empty
        )

    begin{}

    #Need to verify that the hostname is valid in DNS
    process {
        foreach ($Computer in $ComputerName) {
            try {
                $hostdns = [System.Net.DNS]::GetHostEntry($Computer)
                $OS = Get-WmiObject win32_operatingsystem -ComputerName $Computer -ErrorAction Stop -Credential $Credential
                $BootTime = $OS.ConvertToDateTime($OS.LastBootUpTime)
                $Uptime = $OS.ConvertToDateTime($OS.LocalDateTime) - $boottime
                $propHash = [ordered]@{
                    ComputerName = $Computer
                    BootTime     = $BootTime
                    Uptime       = $Uptime
                    }
                $objComputerUptime = New-Object PSOBject -Property $propHash
                $objComputerUptime
                }  
            catch [Exception] {
                Write-Output "$computer $($_.Exception.Message)"
                #return
                }
        }
    }
    end{}
}
while($true){
Get-Uptime -ComputerName SRV-WA
Get-Uptime -ComputerName SRVDB
Get-Uptime -ComputerName SRV-DC1
Get-Uptime -ComputerName SRV-DC2
Get-Uptime -ComputerName SRV-FS
Get-Uptime -ComputerName SRVGW1
Get-Uptime -ComputerName SRV-LEO1
Get-Uptime -ComputerName SRV-LEO2
Get-Uptime -ComputerName SRVMAN1
Get-Uptime -ComputerName SRV-MAN1
Get-Uptime -ComputerName SRV-MAN2
Get-Uptime -ComputerName SRV-VSPHERE
Write-Host
Write-Host
Write-Host "sleeping for 12 seconds"
Write-Host

    $a = Get-Date
    Write-Host Date: $a
    Write-Host -------------------------
Start-Sleep -s 11
}



Captain's Log | Monday 14th of August 2017

nfs mount export not working | linux

rebootI'd followed every guide under the sun, finished with an exportfs -a but kept getting connection timed out when trying to conenct from client. Had to reboot host, this happened the other day as well, same fix.

nfs is shit take 2


was still having issues and came across the below from here. sorted shit out for me.
#!/bin/bash
### BEGIN INIT INFO
# Provides: nfs-re-restart
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 5
# Default-Stop: 0 1 6
# Short-Description: Starts nfs daemin at the end of boot
# Description: restart-nfs
### END INIT INFO

sleep 45
sudo /etc/init.d/nfs-kernel-server stop
logger NFSoff
echo NFS_is_stopping
sudo /etc/init.d/rpcbind stop
logger RPCoff
echo RPC_is_stopping
sudo /etc/init.d/nfs-kernel-server start
logger NFSon
echo NFS_is_starting
sudo /etc/init.d/rpcbind start
logger RPCon
echo RPC_is_starting


Captain's Log | Friday 11th of August 2017

setup bare repo on external server to work with submodules and post-receive hooks, ref | new


on remote:
mkdir /home/www.example.com/public_html && cd /home/www.example.com/public_html
git init
mkdir /home/www.example.com/repo.git && cd /home/www.example.com/repo.git
git init --bare
vim /home/www.example.com/repo.git/hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/home/www.example.com/public_html
GIT_DIR=/home/www.example.com/public_html/.git
cd /home/www.example.com/public_html
git pull /home/www.example.com/repo.git
git submodule sync ; git submodule update --init --recursive
:wq
chmod +x /home/www.example.com/repo.git/hooks/post-receive
  note to rp: see ln site setup for help. well done, now everyone can clone your site from http://www.example.com/.git - make sure you have .git being blocked via .htaccess
  Put this in an .htaccess file at the root of your web server: src
RedirectMatch 404 /\.git

on local:
git clone ssh://example@www.example.com/home/www.example.com/repo.git
cd libraries
  don't do this step if it's a empty new bare repo, go and commit some data first or the .gitmodules file won't be created when run the command below
git submodule add ssh://dave@vpnova.com/home/dave/libraries/tracker.git
cd ..
git commit -av
git push