Skip to content

Instantly share code, notes, and snippets.

@philroche
philroche / zncbackup.sh
Created February 13, 2018 10:44
Backup ZNC config and chat logs
#!/bin/bash
### Facultatif change :
DIR=/data/znc # This will most likely change for you
TAR_PATH=`whereis tar | cut -d ' ' -f 2`
p7zip_PATH=`whereis 7za | cut -d ' ' -f 2`
DATEI1=$(date +%Y-%m-%d)_znc_backup.tar
DATEI2=$(date +%Y-%m-%d)_znc_backup.tar.7z
DATUM=$(date +%Y-%m-%d)
sevenzp="a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on -mhe=on"
### no Change after here
@philroche
philroche / recursive-m4a-convert-to-mp3.sh
Created April 11, 2018 11:55
Recursive convert m4a files to mp3
#!/bin/bash
#
#
#set -ux
set +e
if [ -z "$1" ] ; then
TRANSCODEDIR="."
else
TRANSCODEDIR="$1"
fi
@philroche
philroche / azure-sas-url-and-image-test.sh
Created September 28, 2018 11:39
Script for publishing, booting and gathering logs from a locally produced Azure image
#!/bin/bash
## Pass local .tar.gz path as first argument
# Update the following variables
# This will be created if it does not exist
ACCOUNT_NAME="philrocheubuntu"
# This will be created if it does not exist
CONTAINER="philrocheubuntuimages"
# Customize this as all vm resouces with this group will be cleaned up. This will be created if it does not exist
@philroche
philroche / s3_presigned_url.py
Created October 16, 2018 07:16 — forked from rcj4747/s3_presigned_url.py
Generate a presigned URL to download an S3 object
#!/usr/bin/env python3
"""Generate a presigned URL to download an S3 object
<cmd> bucket_name key_name [expiration_days]"""
import sys
import boto3
from botocore.client import Config
#!/bin/bash -e
## Launch the latest daily Ubuntu in AWS, optionally with user-data
## provided in a file and tagged with a name
function usage() {
echo "$0: [-r region] [-V ubuntu_version] [-i instance_type] \\"
echo " [-u user_data_file] [-n instance_name] [-d disk_size] \\"
echo " [-D] to disable termination via the API"
echo " [-I] iam instance profile [-a AMI ID]"
echo " [-P profile] aws cli profile"
@philroche
philroche / Get the URL to the RTE player video.bookmarklet
Last active May 13, 2019 15:01
Get the URL to the RTE player video
javascript:(function()%7Bfunction%20callback()%7B(function(%24)%7Bvar%20jQuery%3D%24%3Bfunction%20callback()%7Bfunction%20getParameterByName(name%2C%20url)%20%7Bif%20(!url)%20url%20%3D%20window.location.href%3Bname%20%3D%20name.replace(%2F%5B%5C%5B%5C%5D%5D%2Fg%2C%20'%5C%5C%24%26')%3Bvar%20regex%20%3D%20new%20RegExp('%5B%3F%26%5D'%20%2B%20name%20%2B%20'(%3D(%5B%5E%26%23%5D*)%7C%26%7C%23%7C%24)')%2Cresults%20%3D%20regex.exec(url)%3Bif%20(!results)%20return%20null%3Bif%20(!results%5B2%5D)%20return%20''%3Breturn%20decodeURIComponent(results%5B2%5D.replace(%2F%5C%2B%2Fg%2C%20'%20'))%3B%7Dvar%20video_embed_url%20%3D%20getParameterByName(%22pid%22%2C%20%24(%22%23playerpdk%22).attr(%22src%22))%3Bvar%20auth_cookie%20%3D%20Cookies.get('mpx_token')%3Bvar%20auth_video_embed_url%20%3D%20video_embed_url%20%2B%20'%3Fauth%3D'%20%2B%20auth_cookie%20%2B'%26formats%3Dmpeg-dash%26format%3DSMIL%26embedded%3Dtrue%26tracking%3Dtrue'%3Bconsole.log(auth_video_embed_url)%3Bprompt(%22Video%20embed%20URL%20for%20use%20with%20https%3A%2
@philroche
philroche / transmission-openvpn.syno.json
Created November 7, 2019 11:10
Docker config for Synology NAS for docker-transmission-openvpn docker image by haugene (https://github.com/haugene/docker-transmission-openvpn). This config is for Private Internet Access. Also see https://haugene.github.io/docker-transmission-openvpn/synology-nas/ for full guide.
{
"cap_add" : null,
"cap_drop" : null,
"cmd" : "dumb-init /etc/openvpn/start.sh",
"cpu_priority" : 50,
"devices" : null,
"enable_publish_all_ports" : false,
"enable_restart_policy" : false,
"enabled" : false,
"env_variables" : [
@philroche
philroche / cloneawsinstance
Created November 29, 2019 16:44
cloneawsinstance function to clone an aws instance in the same region as the source instance
function cloneinstance {
awsinstanceid=$1
region=${2:-us-east-1}
awsprofile=${3:-seg}
export AWS_DEFAULT_REGION=$region
dt=$(date '+%Y%m%d%H%M%S')
ami=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].ImageId' --output=text)
privatekey=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].KeyName' --output=text)
securitygroup=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].NetworkInterfaces[].Groups[].GroupId' --output=text)
instancetype=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].InstanceType' --output=text)
@philroche
philroche / README.md
Created January 31, 2020 10:10 — forked from smoser/README.md
backdoor-image

backdoor-image

Description

backdoor-image can be used to easily add user with passwordless sudo access to a image or a root filesystem.

Operating on an image requires the 'mount-image-callback' tool from cloud-utils. That can be installed on ubuntu via apt-get install -qy cloud-image-utils.

@philroche
philroche / img-convert
Created April 2, 2020 13:08 — forked from smoser/img-convert
Utility for converting a disk image in raw format or some format qcow understands into VHD format.
#!/bin/bash
VERBOSITY=0
TEMP_D=""
FORMATS=(
qcow2
qcow2-compressed
raw
azure
azure-dynamic
azure-fixed