adding personal scripts
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IPMI IP address
|
||||
IPMIHOST=<hostname>
|
||||
# IPMI Username
|
||||
IPMIUSER=<username
|
||||
# IPMI Password
|
||||
IPMIPW=<password>
|
||||
# Your IPMI Encryption Key
|
||||
IPMIEK=0<IPMI Encryption Key>
|
||||
# Fan Speed / utilisation in percentage, for example 9 for 9% utilisation
|
||||
# Please note that each fan can have a different rpm and will not all be the same speed
|
||||
FANSPEED=10
|
||||
|
||||
# TEMPERATURE
|
||||
# Change this to the temperature in Celsius you are comfortable with.
|
||||
# If the temperature goes above the set degrees it will send raw IPMI command to enable dynamic fan control
|
||||
MAXTEMP=30
|
||||
|
||||
# This variable sends a IPMI command to get the temperature, and outputs it as two digits.
|
||||
# Do not edit unless you know what you do.
|
||||
# Side note, if you are running ipmitool on the system you are controlling, you don't need to specify -H,-U,-P - from the OS installed on the host, ipmitool is assumed permitted. You only need host/user/pass for remote access.
|
||||
TEMP=$(ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK sdr type temperature |grep Ambient |grep degrees |grep -Po '\d{2}' | tail -1)
|
||||
|
||||
# Dont edit this, this converts decimal to hex
|
||||
SPEEDHEX=$( printf "%x" $FANSPEED )
|
||||
|
||||
if [[ $TEMP > $MAXTEMP ]];
|
||||
then
|
||||
printf "Warning: Temperature is too high! Activating dynamic fan control! ($TEMP C)" | systemd-cat -t R710-IPMI-TEMP
|
||||
echo "Warning: Temperature is too high! Activating dynamic fan control! ($TEMP C)"
|
||||
# This sets the fans to auto mode, so the motherboard will set it to a speed that it will need do cool the server down
|
||||
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x01
|
||||
else
|
||||
printf "Temperature is OK ($TEMP C)" | systemd-cat -t R710-IPMI-TEMP
|
||||
printf "Activating manual fan speeds! (1560 RPM)"
|
||||
# This sets the fans to manual mode
|
||||
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x01 0x00
|
||||
# This is where we set the slower, quite speed
|
||||
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW -y $IPMIEK raw 0x30 0x30 0x02 0xff 0x$SPEEDHEX
|
||||
fi
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/python3
|
||||
from subprocess import check_output, run
|
||||
from time import sleep
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def get_time():
|
||||
ts1 = str(datetime.now()).split('.')[0]
|
||||
return ts1
|
||||
|
||||
mountpoints = [
|
||||
'/mnt/main_bridge',
|
||||
'/mnt/engineering',
|
||||
'/mnt/shuttlebay'
|
||||
]
|
||||
|
||||
def main():
|
||||
timestamp = get_time()
|
||||
print(f'Start time: {timestamp}')
|
||||
for mountpoint in mountpoints:
|
||||
run(['umount',mountpoint])
|
||||
run(['mount',mountpoint])
|
||||
timestamp = get_time()
|
||||
print(f'End time: {timestamp}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import glob
|
||||
|
||||
vbProcess = "C:/Program Files (x86)/VideoReDoTVSuite6/vp.vbs"
|
||||
work_dir = "Z:/work_dir/incoming"
|
||||
os.chdir(work_dir)
|
||||
|
||||
project_files = []
|
||||
for file in glob.glob("*.vprj"):
|
||||
project_files.append(file)
|
||||
|
||||
for file in project_files:
|
||||
filename = file.replace('.vprj','.mp4')
|
||||
vbRun = f'cscript //nologo "{vbProcess}" "Z:\\work_dir\\incoming\\{file}" "Z:\\work_dir\\output\\{filename}" /q'
|
||||
print(f'executing {vbRun}')
|
||||
subprocess.run(vbRun)
|
||||
|
||||
exit(0)
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
ipmitool -I lanplus -H 192.168.128.223 -U root -P Optimus0329 -y 0000000000000000000000000000000000000000 power off
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
ipmitool -I lanplus -H 192.168.128.223 -U root -P Optimus0329 -y 0000000000000000000000000000000000000000 power on
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/python3
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from subprocess import check_output, run
|
||||
import time
|
||||
from time import sleep
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def get_time():
|
||||
ts1 = str(datetime.now()).split('.')[0]
|
||||
return ts1
|
||||
|
||||
|
||||
def call_powerup(vmid):
|
||||
run(['/usr/sbin/qm','start',vmid])
|
||||
|
||||
|
||||
def monitor_status(vmid):
|
||||
vmstatus = 'stopped'
|
||||
while vmstatus == 'stopped':
|
||||
sleep(5)
|
||||
vmstatus = check_output(['/usr/sbin/qm','status',vmid])
|
||||
vmstatus = vmstatus.decode().split(': ')[1].rstrip()
|
||||
return 'Done'
|
||||
|
||||
|
||||
def main():
|
||||
timestamp = get_time()
|
||||
print(f'Start time: {timestamp}')
|
||||
vms = ['105']
|
||||
for vm in vms:
|
||||
try:
|
||||
print(f'starting up {vm}')
|
||||
call_powerup(vm)
|
||||
vresult = monitor_status(vm)
|
||||
print(f'{vresult}')
|
||||
except Exception as e:
|
||||
print(f'{vm} currently not running')
|
||||
timestamp = get_time()
|
||||
print(f'End time: {timestamp}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/python
|
||||
import glob
|
||||
import os
|
||||
from pathlib2 import Path
|
||||
|
||||
dir_list = []
|
||||
p = "/Volumes/engineering/media/Television"
|
||||
for directory in [str(item) for item in Path(p).rglob(".")]:
|
||||
if 'Season' in directory:
|
||||
dir_list.append(directory)
|
||||
|
||||
for directory in dir_list:
|
||||
file_list = os.walk(directory)
|
||||
for filelist in file_list:
|
||||
flist = filelist[2]
|
||||
for filename in filelist[2]:
|
||||
fname = str.encode(filename)
|
||||
if str.encode('tvrenametemp') in fname:
|
||||
oldfile = f'{directory}/{filename}'
|
||||
newfile = f'{directory}/{filename.replace(".tvrenametemp","")}'
|
||||
print(f'Renaming {newfile} to {newfile}')
|
||||
os.rename(oldfile, newfile)
|
||||
|
||||
exit()
|
||||
@@ -0,0 +1,29 @@
|
||||
### Trim Proxmox host volumes and all LXCs on node ###
|
||||
# Run as weekly cron job
|
||||
# !/bin/bash
|
||||
|
||||
# Script colors
|
||||
green=`tput setaf 2`
|
||||
reset=`tput sgr0`
|
||||
|
||||
# Path to FSTRIM
|
||||
FSTRIM=/sbin/fstrim
|
||||
|
||||
# List of host volumes to trim separated by spaces
|
||||
# eg TRIMVOLS="/mnt/a /mnt/b /mnt/c"
|
||||
TRIMVOLS="/"
|
||||
|
||||
## Trim all LXC containers ##
|
||||
echo "${green}LXC CONTAINERS${reset}"
|
||||
for i in $(pct list | awk '/^[0-9]/ {print $1}'); do
|
||||
echo "Trimming Container $i"
|
||||
pct fstrim $i 2>&1 | logger -t "pct fstrim [$$]"
|
||||
done
|
||||
echo ""
|
||||
|
||||
## Trim host volumes ##
|
||||
echo "${green}HOST VOLUMES${reset}"
|
||||
for i in $TRIMVOLS; do
|
||||
echo "Trimming $i"
|
||||
$FSTRIM -v $i 2>&1 | logger -t "fstrim [$$]"
|
||||
done
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/python3
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from subprocess import check_output, run
|
||||
import time
|
||||
from time import sleep
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def get_time():
|
||||
ts1 = str(datetime.now()).split('.')[0]
|
||||
return ts1
|
||||
|
||||
|
||||
def call_vm_shutdown(vmid):
|
||||
run(['/usr/sbin/qm','shutdown',vmid])
|
||||
|
||||
def call_lxc_shutdown(lxc):
|
||||
run(['/usr/bin/lxc-stop',lxc])
|
||||
|
||||
def get_status(vmid):
|
||||
vmstatus = check_output(['/usr/sbin/qm','shutdown',vmid])
|
||||
vmstatus = vmstatus.decode().split(': ')[1].rstrip()
|
||||
return vmstatus
|
||||
|
||||
|
||||
def monitor_status(vmid):
|
||||
vmstatus = 'running'
|
||||
while vmstatus == 'running':
|
||||
sleep(5)
|
||||
vmstatus = check_output(['/usr/sbin/qm','status',vmid])
|
||||
vmstatus = vmstatus.decode().split(': ')[1].rstrip()
|
||||
return 'Done'
|
||||
|
||||
def lxc_status(lxc):
|
||||
vmstatus = 'running'
|
||||
while vmstatus.lower() == 'running':
|
||||
sleep(5)
|
||||
vmoutput = check_output(['lxc-info', lxc])
|
||||
if b'RUNNING' not in vmoutput:
|
||||
vmstatus = 'stopped'
|
||||
#vmstatus = vmstatus.decode().split(': ')[1].rstrip()
|
||||
print(vmstatus)
|
||||
return 'Done'
|
||||
|
||||
def shutdown_host():
|
||||
run(['/usr/sbin/init','0'])
|
||||
|
||||
def main():
|
||||
timestamp = get_time()
|
||||
print(f'Start time: {timestamp}')
|
||||
vms = ['115', '109', '108', '107', '101']
|
||||
for vm in vms:
|
||||
try:
|
||||
print(f'Shutting down {vm}')
|
||||
call_vm_shutdown(vm)
|
||||
vresult = monitor_status(vm)
|
||||
print(f'{vresult}')
|
||||
except Exception as e:
|
||||
print(f'{vm} currently not running')
|
||||
lxcs = ['110', '114', '113', '111', '103', '104', '105', '112']
|
||||
for lxc in lxcs:
|
||||
try:
|
||||
print(f'Shutting down {lxc}')
|
||||
call_lxc_shutdown(lxc)
|
||||
vresult = lxc_status(lxc)
|
||||
print(f'{vresult}')
|
||||
except Exception as e:
|
||||
print(f'{lxc} currently not running')
|
||||
timestamp = get_time()
|
||||
print(f'End time: {timestamp}')
|
||||
#shutdown_host()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user