Download file with PowerShell

So .. I have a windows embedded which doesn’t have internet explorer .. nor explorer shell .. nor any other methods of communicating with the universe ( except the internet itself and ftp ) .. but I had the bright idea to embed powershell !
After a couple of hours of trying to figure out why the heck to my apps keep saying “don’t want to run in DOS mode” .. or not running anything at all ( and weird icons apearing for the app instead of the icon I’d expect it to have ) .. I got to this:

$storageDir = $pwd
$webclient = New-Object System.Net.WebClient
$url = "http://link/to/file"
$file = "$storageDir\myNewFilename.jpg"

I don’t know exactly why the ftp method didn’t work YET ..

Creating a Windows Embedded Standard 7 ISO

So, first step is to get en_windows_embedded_standard_7_sp1_toolkit_x86_dvd_651894.iso ( or whatever is newer .. )
You can get a trial from Windows Embedded Standard 7 HomePage.

After that, you want to follow this Building a Windows Embedded Standard 7 Image DeveloperNetwork Page. What it basically sais is:
– you need to run tap.exe on your windows target machine to get information about the drivers it needs installed !
– get the mpq file it generated
– create your IBW directory ( I generated mine in c:\users\dexter\desktop\embedded7img )

After that, you probably want to do this

"c:\Program Files (x86)\Windows Embedded Standard 7\Tools\AMD64\oscdimg.exe" -n -m -b"C:\users\dexter\desktop\embdedded7img\boot\" "c:\users\asandu\desktop\embedded7img" "c:\users\asandu\desktop\embedded7img.iso" 

Et voila, you have a windows embdeded 7 bootable iso image.

P.S.: You probably want “Windows Explorer Shell” if you want your familiar desktop instead of the “Command Prompt Shell with Custom Shell Support”

OpenVPN setup with mysql auth and ssl port sharing

So, I decided it was time to prevent some firewalls from blocking my connection to openvpn.
Here’s what I did to share port 443 ( which I already had an apache listening on ) with openvpn !

# Make apache Listen on port 4545 and replace all VirtualHost directives to use that.
emerge net-misc/openvpn app-crypt/easy-rsa sys-auth/pam_mysql
cp -prv /usr/share/easy-rsa ~
cd ~/easy-rsa
cp vars{,.orig}
cat >> vars << _EOF_
export EASY_RSA="`pwd`"
export KEY_DIR="$EASY_RSA/keys"
export OPENSSL="openssl"
export PKCS11TOOL="pkcs11-tool"
export GREP="grep"
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`
export KEY_SIZE=4096
export CA_EXPIRE=3650
export KEY_EXPIRE=3650
export KEY_CITY="Miami"
export KEY_ORG="Fort-Funston"
export KEY_EMAIL="master@myhost.domain"
export KEY_CN=changeme # Common Name (eg, your name or your server's hostname) 
export KEY_NAME=changeme # Name
export KEY_OU=changeme # Organizational Unit Name (eg, section)
source ./vars
./build-key-server server
openvpn --genkey --secret /root/easy-rsa/keys/ta.key
mkdir -p /etc/openvpn/certs
cp -pv ~/easy-rsa/keys/{ca.crt,ca.key,server.crt,server.key,ta.key,dh4096.pem} /etc/openvpn/certs/

cat >> /etc/openvpn/openvpn.conf << _EOF_
dev tun
# use udp .. it performs alot better, this tutorial just uses tcp because it is sharing the port with apache !
proto tcp
local # replace with the ip you want it listening instead of
port 443
port-share 4545
keepalive 10 120
user nobody
group nobody
ca /etc/openvpn/certs/ca.crt
cert /etc/openvpn/certs/server.crt
key /etc/openvpn/certs/server.key
dh /etc/openvpn/certs/dh2048.pem
tls-auth /etc/openvpn/certs/ta.key
tls-version-min 1.2 # you can try use tls-cipher see if everything is ok for you, if not, try this.
cipher AES-256-CBC
auth SHA384
verb 5

sed -i 's/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/' /etc/sysctl.conf
sysctl -p
rc-update add openvpn default
/etc/init.d/apache2 restart
/etc/init.d/openvpn restart

# now for the client part, give him this one file
./build-key-pass client
cat >> ~/client.ovpn << _EOF_
dev tun
# set udp here too if you decided to use that!
proto tcp
port 443
cipher AES-256-CBC
comp-lzo yes
script-security 2
auth sha384

$(cat ~/easy-rsa/keys/ca.crt)

$(cat ~/easy-rsa/keys/client.crt)

$(cat ~/easy-rsa/keys/client.key)

$(cat ~/easy-rsa/keys/ta.key)

Gentoo apache 2.4 and Google’s mod_pagespeed

Here’s how you can get mod_pagespeed on your gentoo box running apache 2.4

emerge rpm
mkdir ~/src
wget -O ~/src/mod-pagespeed-stable_current_x86_64.rpm  
cd ~/src
cpio ~/src/mod-pagespeed-stable_current_x86_64.rpm | cpio -idmv
cp ~/src/usr/lib64/httpd/modules/ /usr/lib64/apache2/modules/
cp ~/src/etc/httpd/conf.d/pagespeed.conf /etc/apache2/modules.d/80_mod_pagespeed.conf
cp ~/src/etc/httpd/conf.d/pagespeed_libraries.conf /etc/apache2/modules.d/
mkdir /var/cache/mod_pagespeed/ -p
chown -R apache:apache /var/cache/mod_pagespeed/
# You'll need to have mod_version installed or you'll have to manually set the LoadModule to use the one.
# You'll also have to replace /usr/lib64/httpd with /usr/lib64/apache2
sed -i 's/\/usr\/lib64\/httpd/\/usr\/lib64\/apache2/' /etc/apache2/modules.d/80_mod_pagespeed.conf 
# Replace the Order and Allow lines with 'Require all granted'
/etc/init.d/apache2 restart

Many thanks go to tantruminv.comfor providing the initial info.

Installing Oracle’s JRE in gentoo

It’s as simple as this:

echo '>=dev-java/oracle-jre-bin- Oracle-BCLA-JavaSE' >> /etc/portage/package.license

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" ""

mv jre-7u65-linux-x64.tar.gz /usr/portage/distfiles

emerge =dev-java/oracle-jre-bin-

java-config --list-available-vms # to see the VMS installed

java-config --set-system-vm oracle-jre-bin-1.7

You might have to update the link and version number since it might ( and will probably ) change since I wrote this post.

wget oracle jre

A simple way to get the jre without going through the headaches of oracle’s disabled direct downloads is this:

wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" ""                                                  

You can check the latest links by going to Java SE Runtime Environment 8 Downloads Page for example ( others available on the Java SE Downloads Page ), clicking ‘Accept License Agreement’ and copying the links of the wanted files.

youtube-dl and ffmpeg volume raise

So .. I’ve been wanting to see some youtube tuts/audio offline while I comute ..

But the volume is pretty low, either from the video .. or my android tablet .. and I know I can raise the volume from the DSP Manager but I don’t want to need to change it back again for other videos ..

Here’s how I did it on my gentoo system.

# you might want to unmask a newer version
# echo '<=net-misc/youtube-dl-2014.10.18 ~amd64' >> /etc/portage/package.keywords
emerge youtube-dl
# Here's how you get the mp3 only version
youtube-dl -x --audio-format mp3
#other help
youtube-dl --help

This is the easy part !
Now, you probably want to raise the volume a lil’ bit ..

ffmpeg -i file.mp3 -vol 400 output.mp3
# 256 is normal, if you use 512 then it will double the volume.
# you can't use -acodec copy because -acodec copy and -vol are incompatible (frames are not decoded)