Desktop scripts
This commit is contained in:
parent
6079f98037
commit
639e4dbf2d
19 changed files with 321 additions and 0 deletions
3
scripts/checkport
Executable file
3
scripts/checkport
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Check if port is used
|
||||||
|
sudo lsof -i:$1
|
||||||
27
scripts/connect-nfs
Executable file
27
scripts/connect-nfs
Executable file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Connects remote nfs filesystems
|
||||||
|
if [ $# -eq 2 ]; then
|
||||||
|
echo "Mounting $1"
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/$1 /mnt/nfs/$1
|
||||||
|
echo "Mounting $2"
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/$2 /mnt/nfs/$2
|
||||||
|
elif [ $# -gt 2 ]; then
|
||||||
|
echo "Mounting $1"
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/$1 /mnt/nfs/$1
|
||||||
|
echo "Mounting $2"
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/$2 /mnt/nfs/$2
|
||||||
|
echo "Mounting $3"
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/$3 /mnt/nfs/$3
|
||||||
|
elif [ $# -eq 1 ]; then
|
||||||
|
echo "Mounting $1"
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/$1 /mnt/nfs/$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/Music /mnt/nfs/Music
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/Downloads /mnt/nfs/Downloads
|
||||||
|
sudo mount -t nfs -o vers=4 10.8.0.1:/mnt/Video /mnt/nfs/Video
|
||||||
|
echo "Mounted Music, Downloads and Video"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
48
scripts/create_container
Executable file
48
scripts/create_container
Executable file
|
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Debian containers only
|
||||||
|
function create_container {
|
||||||
|
echo -n "Enter the path of the container (including container root): "
|
||||||
|
read -e CONTAINER_PATH
|
||||||
|
|
||||||
|
echo -n "Enter debian release channel: "
|
||||||
|
read CHANNEL
|
||||||
|
|
||||||
|
echo -n "Enter (private) ssh key for git (absolute path): "
|
||||||
|
read -e KEY
|
||||||
|
|
||||||
|
echo "Creating container.."
|
||||||
|
debootstrap $CHANNEL $CONTAINER_PATH
|
||||||
|
mkdir $CONTAINER_PATH/root/.bin/
|
||||||
|
|
||||||
|
echo "Copying key.."
|
||||||
|
mkdir $CONTAINER_PATH/root/.ssh
|
||||||
|
cp $KEY $KEY.pub $CONTAINER_PATH/root/.ssh/
|
||||||
|
|
||||||
|
echo -n "Start a ssh server? [y/n]: "
|
||||||
|
read SSH_SERVER
|
||||||
|
|
||||||
|
if [ "$SSH_SERVER" == "y" ] ;then
|
||||||
|
systemd-nspawn -D $CONTAINER_PATH apt-get install ssh
|
||||||
|
add_ssh $CONTAINER_PATH
|
||||||
|
elif [ -z "$SSH_SERVER" ] ;then
|
||||||
|
echo "Not creating a ssh server"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing vim & git"
|
||||||
|
systemd-nspawn -D $CONTAINER_PATH apt-get install vim git
|
||||||
|
|
||||||
|
echo "Starting container first time, enter root pass"
|
||||||
|
systemd-nspawn -D $CONTAINER_PATH passwd
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_ssh {
|
||||||
|
echo -n "Enter ssh listening port: "
|
||||||
|
read PORT
|
||||||
|
|
||||||
|
echo "Editing ssh config"
|
||||||
|
# edit ssh config
|
||||||
|
sed -i 's/^#Port .*/Port '"$PORT"'/' $1/etc/ssh/sshd_config
|
||||||
|
sed -i 's/^#PermitRootLogin .*/PermitRootLogin yes/' $1/etc/ssh/sshd_config
|
||||||
|
}
|
||||||
|
|
||||||
|
create_container
|
||||||
26
scripts/disconnect-nfs
Executable file
26
scripts/disconnect-nfs
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#COUNT=0
|
||||||
|
#ARRAY=()
|
||||||
|
if [ -n "$(ls -A /mnt/nfs/Downloads)" ]; then
|
||||||
|
DOWNLOADS="Downloads"
|
||||||
|
echo "Unmounting $DOWNLOADS"
|
||||||
|
if sudo umount /mnt/nfs/$DOWNLOADS ; then
|
||||||
|
echo "Unmounted $DOWNLOADS"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(ls -A /mnt/nfs/Music)" ]; then
|
||||||
|
MUSIC="Music"
|
||||||
|
echo "Unmounting $MUSIC"
|
||||||
|
if sudo umount /mnt/nfs/$MUSIC ; then
|
||||||
|
echo "Unmounted $MUSIC"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(ls -A /mnt/nfs/Video)" ]; then
|
||||||
|
VIDEO="Video"
|
||||||
|
echo "Unmounting $VIDEO"
|
||||||
|
if sudo umount /mnt/nfs/$VIDEO ; then
|
||||||
|
echo "Unmounted $VIDEO"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
4
scripts/pubip
Executable file
4
scripts/pubip
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
## Get public IP
|
||||||
|
|
||||||
|
wget http://ipinfo.io/ip -qO -
|
||||||
11
scripts/qemu/debian-unstable
Executable file
11
scripts/qemu/debian-unstable
Executable file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
qemu-system-x86_64 -enable-kvm --daemonize \
|
||||||
|
-cpu host \
|
||||||
|
-drive format=raw,file="/media/platvoeten/VM/debian-unstable.img",if=virtio \
|
||||||
|
-m 4G \
|
||||||
|
-name "debian-unstable" \
|
||||||
|
-vga qxl \
|
||||||
|
-spice port="5922",disable-ticketing \
|
||||||
|
-device virtio-serial \
|
||||||
|
-chardev spicevmc,id=vdagent,name=vdagent \
|
||||||
|
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0
|
||||||
12
scripts/qemu/kubuntu-1704
Executable file
12
scripts/qemu/kubuntu-1704
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
qemu-system-x86_64 -enable-kvm --daemonize \
|
||||||
|
-cpu host \
|
||||||
|
-drive format=raw,file="/media/platvoeten/VM/ubuntu-1704.img",if=virtio \
|
||||||
|
-m 4G \
|
||||||
|
-name "kubuntu-1704" \
|
||||||
|
-vga qxl \
|
||||||
|
-spice port="5930",disable-ticketing \
|
||||||
|
-device virtio-serial \
|
||||||
|
-chardev spicevmc,id=vdagent,name=vdagent \
|
||||||
|
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0 &&
|
||||||
|
exec spicy --title "kubuntu-1704" 127.0.0.1 -p "5930"
|
||||||
94
scripts/qemu/qemu-helper
Executable file
94
scripts/qemu/qemu-helper
Executable file
|
|
@ -0,0 +1,94 @@
|
||||||
|
#!/bin/bash
|
||||||
|
## Script to create and or edit a qemu script
|
||||||
|
function create_script {
|
||||||
|
echo -n "Create VM image? [y/n]: "
|
||||||
|
read IMAGE
|
||||||
|
|
||||||
|
## Optional image creation
|
||||||
|
if [ "$IMAGE" == "y" ] ;then
|
||||||
|
echo -n "Enter the the path of the image: "
|
||||||
|
read IMAGE_NAME
|
||||||
|
DISK=$IMAGE_NAME
|
||||||
|
echo -n "Enter the size of the image [10G/5G]: "
|
||||||
|
read SIZE
|
||||||
|
qemu-img create -f raw "$IMAGE_NAME" "$SIZE"
|
||||||
|
elif [ -z "$IMAGE" ] ;then
|
||||||
|
echo -n "Enter the Disk path and press [ENTER]: "
|
||||||
|
read DISK
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "Boot disk needed? [y/n]: "
|
||||||
|
read ANSWER
|
||||||
|
if [ "$ANSWER" == "y" ] ;then
|
||||||
|
echo -n "Enter the Boot disk path and press [ENTER]: "
|
||||||
|
read BOOT_DISK
|
||||||
|
else
|
||||||
|
echo "Okay, dropping boot disk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "Enter the VM name and press [ENTER]: "
|
||||||
|
read NAME
|
||||||
|
|
||||||
|
echo -n "Enter the port number and press [ENTER]: "
|
||||||
|
read PORT
|
||||||
|
|
||||||
|
echo -n "Enter qemu script's name and press [ENTER]: "
|
||||||
|
read FILE
|
||||||
|
|
||||||
|
# Creation of script
|
||||||
|
touch "$HOME/.bin/qemu/$FILE"
|
||||||
|
chmod +x "$HOME/.bin/qemu/$FILE"
|
||||||
|
|
||||||
|
if [ "$ANSWER" == "y" ] ;then
|
||||||
|
cat <<EOF > "$HOME/.bin/qemu/$FILE"
|
||||||
|
#!/bin/bash
|
||||||
|
qemu-system-x86_64 -enable-kvm --daemonize '\'
|
||||||
|
-cpu host '\'
|
||||||
|
-drive format=raw,file="$DISK",if=virtio '\'
|
||||||
|
-boot d -cdrom "$BOOT_DISK" '\'
|
||||||
|
-m 4G '\'
|
||||||
|
-name "$NAME" '\'
|
||||||
|
-vga qxl '\'
|
||||||
|
-spice port="$PORT",disable-ticketing '\'
|
||||||
|
-device virtio-serial '\'
|
||||||
|
-chardev spicevmc,id=vdagent,name=vdagent '\'
|
||||||
|
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0 &&
|
||||||
|
exec spicy --title "$NAME" 127.0.0.1 -p "$PORT"
|
||||||
|
EOF
|
||||||
|
elif [ "$ANSWER" == "n" ] ;then
|
||||||
|
cat <<EOF > "$HOME/.bin/qemu/$FILE"
|
||||||
|
#!/bin/bash
|
||||||
|
qemu-system-x86_64 -enable-kvm --daemonize '\'
|
||||||
|
-cpu host '\'
|
||||||
|
-drive format=raw,file="$DISK",if=virtio '\'
|
||||||
|
-m 4G '\'
|
||||||
|
-name "$NAME" '\'
|
||||||
|
-vga qxl '\'
|
||||||
|
-spice port="$PORT",disable-ticketing '\'
|
||||||
|
-device virtio-serial '\'
|
||||||
|
-chardev spicevmc,id=vdagent,name=vdagent '\'
|
||||||
|
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0 &&
|
||||||
|
exec spicy --title "$NAME" 127.0.0.1 -p "$PORT"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fix
|
||||||
|
## Remove '' from \
|
||||||
|
sed -i "s/'//g" "$HOME/.bin/qemu/$FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
## Remove GUI options for headless VM
|
||||||
|
function remove_gui {
|
||||||
|
sed -i "/-vga\|-spice\|virtio-serial\|-chardev\|exec/d" "$HOME/.bin/qemu/$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo -n "Do you want to create a qemu script or remove the gui from a script? [create/remove]: "
|
||||||
|
read FUNCTION
|
||||||
|
|
||||||
|
if [ "$FUNCTION" == "create" ] ;then
|
||||||
|
create_script
|
||||||
|
elif [ "$FUNCTION" == "remove" ] ;then
|
||||||
|
echo "Enter script's file path and press [Enter]: "
|
||||||
|
read FILENAME
|
||||||
|
remove_gui $FILENAME
|
||||||
|
fi
|
||||||
14
scripts/qemu/raspbian
Executable file
14
scripts/qemu/raspbian
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Qemu script to start raspbian
|
||||||
|
qemu-system-arm \
|
||||||
|
-kernel /media/platvoeten/Downloads/kernel-qemu-4.4.34-jessie \
|
||||||
|
-cpu arm1176 \
|
||||||
|
-net user,hostfwd=tcp::2222-:22 \
|
||||||
|
-net nic \
|
||||||
|
-display none \
|
||||||
|
-m 256 \
|
||||||
|
-no-reboot \
|
||||||
|
-M versatilepb \
|
||||||
|
-serial stdio\
|
||||||
|
-append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \
|
||||||
|
-drive "file=/media/platvoeten/VM/raspbian.img,index=0,media=disk,format=raw"
|
||||||
12
scripts/qemu/ubuntu-desktop
Executable file
12
scripts/qemu/ubuntu-desktop
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
qemu-system-x86_64 -enable-kvm --daemonize \
|
||||||
|
-cpu host \
|
||||||
|
-drive format=raw,file="/media/platvoeten/VM/ubuntu/ubuntu-desktop.img",if=virtio \
|
||||||
|
-name "ubuntu-desktop" \
|
||||||
|
-vga qxl \
|
||||||
|
-redir tcp:5560::22 \
|
||||||
|
-m 3G \
|
||||||
|
-spice port="5929",disable-ticketing \
|
||||||
|
-device virtio-serial \
|
||||||
|
-chardev spicevmc,id=vdagent,name=vdagent \
|
||||||
|
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0
|
||||||
12
scripts/qemu/ubuntu-server
Executable file
12
scripts/qemu/ubuntu-server
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
qemu-system-x86_64 -enable-kvm --daemonize \
|
||||||
|
-cpu host \
|
||||||
|
-drive format=raw,file="/media/platvoeten/VM/ubuntu/ubuntu-server.img",if=virtio \
|
||||||
|
-netdev user,id=vmnic,hostfwd=tcp::5555-:22,hostfwd=tcp::5556-:8000,hostname=ubuntu-server -device virtio-net,netdev=vmnic \
|
||||||
|
-m 1G \
|
||||||
|
-name "ubuntu-server" \
|
||||||
|
-vga qxl \
|
||||||
|
-spice port="5927",disable-ticketing \
|
||||||
|
-device virtio-serial \
|
||||||
|
-chardev spicevmc,id=vdagent,name=vdagent \
|
||||||
|
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0
|
||||||
9
scripts/qemu/ubuntu-server.old
Executable file
9
scripts/qemu/ubuntu-server.old
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
qemu-system-x86_64 -enable-kvm \
|
||||||
|
-cpu host \
|
||||||
|
-drive format=raw,file="/media/platvoeten/VM/ubuntu/ubuntu-server.img",if=virtio \
|
||||||
|
-drive format=raw,file="/media/platvoeten/VM/test-hdd.img",if=virtio \
|
||||||
|
-netdev user,id=vmnic,smb=/home/platvoeten,hostfwd=tcp::5555-:22,hostfwd=tcp::5556-:8000,hostname=ubuntu-server -device virtio-net,netdev=vmnic \
|
||||||
|
-display none \
|
||||||
|
-m 1G \
|
||||||
|
-name "ubuntu-server" \
|
||||||
1
scripts/qemu/variables/ubuntu-server
Normal file
1
scripts/qemu/variables/ubuntu-server
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
OPTIONS="-enable-kvm --daemonize -cpu host -drive format=raw,file=/media/platvoeten/VM/ubuntu-server.img,if=virtio -netdev user,id=vmnic,hostname=ubuntu-server -device virtio-net,netdev=vmnic -redir tcp:5555::22 -m 4G -spice port=5925,disable-ticketing -device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0"
|
||||||
1
scripts/qemu/variables/win10
Normal file
1
scripts/qemu/variables/win10
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
OPTIONS="-enable-kvm --daemonize -cpu host -boot d -cdrom /media/platvoeten/Downloads/Windows_iso/Win10_English_x64.iso -drive file=/media/platvoeten/Downloads/virtio-win-0.1.126.iso,index=3,media=cdrom -drive format=raw,file=/media/platvoeten/VM/Windows.img,if=virtio -net nic -net user,hostname=Windows10,smb=/home/platvoeten/Sync/Inholland -m 3G -name Windows-10 -spice port=5928,disable-ticketing -device virtio-serial -chardev spicevmc,id=vdagent,name=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0"
|
||||||
14
scripts/qemu/windows10
Executable file
14
scripts/qemu/windows10
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
## Windows 10 Virtio VM
|
||||||
|
qemu-system-x86_64 -enable-kvm \
|
||||||
|
-cpu host \
|
||||||
|
-drive file=/media/platvoeten/Downloads/virtio-win-0.1.126.iso,index=3,media=cdrom \
|
||||||
|
-cdrom /dev/cdrom \
|
||||||
|
-drive format=raw,file=/media/platvoeten/VM/windows10.img,if=virtio \
|
||||||
|
-netdev user,id=vmnic,smb=/home/platvoeten/Sync/Inholland,hostname=windows10 -device virtio-net,netdev=vmnic \
|
||||||
|
-m 4G \
|
||||||
|
-name "Windows 10" \
|
||||||
|
-spice port=5928,disable-ticketing \
|
||||||
|
-device virtio-serial \
|
||||||
|
-chardev spicevmc,id=vdagent,name=vdagent \
|
||||||
|
-device virtserialport,chardev=vdagent,name=com.redhat.spice.0
|
||||||
8
scripts/scan-network
Executable file
8
scripts/scan-network
Executable file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#Why does it not work all the time ?
|
||||||
|
#When this command runs nmap tries to ping the given IP address range to check if the hosts are alive. If ping fails it tries to send syn packets to port 80 (SYN scan). This is not hundred percent reliable because modern host based firewalls block ping and port 80. Windows firewall blocks ping by default. The hosts you have on the network are blocking ping and the port 80 is not accepting connections. Hence nmap assumes that the host is not up.
|
||||||
|
|
||||||
|
# $1 = ip gateway
|
||||||
|
# example 192.168.178.1/24
|
||||||
|
|
||||||
|
nmap -sP $1
|
||||||
10
scripts/shortcuts/shortcuts
Executable file
10
scripts/shortcuts/shortcuts
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
## Interactive prompt to show linux syntax
|
||||||
|
Shortcuts=$HOME/Sync/Linux/Syntax/*
|
||||||
|
echo "Which shortcut would you like to be shown?"
|
||||||
|
for file in $Shortcuts; do
|
||||||
|
echo $file
|
||||||
|
done
|
||||||
|
read input_variable
|
||||||
|
echo "You've selected $input_variable'"
|
||||||
|
cat $HOME/Sync/Linux/Syntax/$input_variable
|
||||||
6
scripts/ssh-forward
Executable file
6
scripts/ssh-forward
Executable file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#Possible to close after execution!
|
||||||
|
#Hostname = $1
|
||||||
|
#Local port = $2
|
||||||
|
#Remote port = $3
|
||||||
|
ssh -N $1 -L $2:localhost:$3
|
||||||
9
scripts/tmux_start
Executable file
9
scripts/tmux_start
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#tmux start-server;
|
||||||
|
tmux new-session -d -s Main;
|
||||||
|
tmux new-window -t Main;
|
||||||
|
tmux new-window -t Main;
|
||||||
|
tmux new-session -d -s Development;
|
||||||
|
tmux split-window -t Development;
|
||||||
|
tmux new-window -t Development;
|
||||||
|
tmux new-window -t Development;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue