Autogenerate “PopArt”

This one downloads images from google and applies imagemagick filters to them to convert them in pseudo-PopArt-ish images

 

#!/bin/bash

function getimages {
#set -x
QUERY=`shuf -n 1 /scripts/POPART/wallpaper-subjects.txt| sed ‘s/ /%20/g’`
mkdir -p /var/www/popart
cd /var/www/popart
rm -fR /var/www/popart/*
for page in 1 2 3 4;do
        i=$(((${page}-1)*21))
        curl -m 2 -A “Mozilla/3.0 (compatible; AvantGo 3.2)” “http://images.google.com/images?as_q=${QUERY}&safe=off&start=${i}&biw=800&bih=600&as_st=y&tbm=isch&tbs=ic:white,iar:s” 2>/dev/null |sed -e ‘s/>/>\n/g’ | awk ‘{s=substr($0,index($0,”imgurl=”),index($0,”&”));print substr(s,1,index(s,”&”)-1)}’ | grep imgurl|sed ‘s/imgurl=//g’| egrep -v ‘starkeith|gstatic|scaredmonkeys|tripod|flickr’|sed ‘s/2520/20/g’ | while read url;do
(
                F=`echo $url | awk -F’\/’ ‘{ print $NF }’`
                t=`echo “${F}”| tr -d “[:punct:]“|sed “s/;//g;s/:/_/g;s/\*//g;s/ó/o/g;s/í/i/g;s/ú/u/g;s/á/a/g;s/é/e/g;s/ñ/n/g;s/\&/And/g;s/-/_/g;s/%//g;s/ /_/g;s/(//g;s/)//g;s/\[//g;s/\]//g;s/’//g;s/,/_/g” | tr -s ‘_’|tr ‘[:upper:]‘ ‘[:lower:]‘ |sed ‘s/\([a-z]\)\([a-zA-Z0-9]*\)/\u\1\2/g;s/Mp3/mp3/g’| sed ‘s/mp3//g;s/U0026quot//g;s/U0026amp//g;s/U0026amp//g;s/_amp_//g’| sed ‘s/\\\//g’`
                wget -O $t –timeout=10 $url
                transform “$t”
) &
        done
done
}

function transform {
f=”$@”
set -x
cd /var/www/popart
A=$(($RANDOM%50))
B=$(($RANDOM%50))
C=$(($RANDOM%50))
D=$(($RANDOM%50))

convert -colorspace Gray -resize 900 -page -$A-$B “$f” -background white -flatten -contrast-stretch 40% -fuzz 70% -colorspace RGB -fill “blue” -opaque black “a_$f”
convert -colorspace Gray -resize 900 -page +$C+$D “$f” -background white -flatten -contrast-stretch 40% -fuzz 70% -colorspace RGB -fill “red” -opaque black “b_$f”
convert -colorspace Gray -resize 900 -page -$D-$B “$f” -background white -flatten -contrast-stretch 40% -fuzz 70% -colorspace RGB -fill “green” -opaque black  “c_$f”
convert -colorspace Gray -resize 900 -page +$A+$C “$f” -background white -flatten -contrast-stretch 40% -fuzz 70% -colorspace RGB -fill “orange” -opaque black “d_$f”

convert “$f” -colorspace Gray -resize 900 -contrast-stretch 10% \( “a_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay -composite e_$f
convert “$f” -colorspace Gray -resize 900 -contrast-stretch 10% \( “b_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay -composite f_$f
convert “$f” -colorspace Gray -resize 900 -contrast-stretch 10% \( “c_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay -composite g_$f
convert “$f” -colorspace Gray -resize 900 -contrast-stretch 10% \( “d_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay -composite h_$f
convert “$f” -colorspace Gray -resize 900 -contrast-stretch 10% \( “a_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay \( “b_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay \( “c_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay \( “d_$f” -alpha set -channel A -fx ’0.8′ \) -compose Overlay -composite i_$f

rm “a_$f” “b_$f” “c_$f” “d_$f”
}

getimages

Prepare a zfs pool to boot from it

My jumpstart install uncompresses the flar but leaves the server without bootblock or zfs bootpool, to fix this i install the bootblock and set the zpool’s bootfs property

# zpool status
  pool: rpool
 state: ONLINE
 scan: none requested
config:

        NAME          STATE     READ WRITE CKSUM
        rpool         ONLINE       0     0     0
          mirror-0    ONLINE       0     0     0
            c0t0d0s0  ONLINE       0     0     0
            c0t1d0s0  ONLINE       0     0     0

# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c0t0d0s0
# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c0t1d0s0

# zpool set bootfs=rpool/ROOT/sol10u11sparc rpool

Then just… reboot

 

 

Reborn

This time, kraftek.com is running in a webserver inside an appletv :) appletv_hero

During its lifetime it has run in various x86 and x86_64 slackware linux boxes+laptops, a couple of ubuntu laptops, a rikomagic ARM cpu device running picuntu linux, and now, an appletv running a jailbroken iOS. Next, i’d like it to run in a dd-wrt router, which i already own…. :)

CDOM and LDOM config

If your server doesn’t have a CDOM, you could create one by running something like this (create_config.ksh):

ldm add-vdiskserver primary-vds0 primary
 ldm add-vconscon port-range=5000-5100  primary-vcc0 primary
 ldm add-vswitch net-dev=igb0 primary-vsw0 primary
 ldm add-vswitch net-dev=nxge0 primary-vsw1 primary
 ldm set-vcpu 4 primary
 ldm set-memory 1g primary
 ldm add-config initial
 ldm list-config

 

Reboot the server.

Now let’s say you want to create an LDOM in that server, login to the cdom and do something like this (create_myldom.ksh):

ldm add-domain myldom
ldm set-vcpu 16 myldom
ldm set-memory 13G myldom
ldm add-vnet vnet1 primary-vsw0 myldom
ldm add-vnet vnet2 primary-vsw1 myldom
 ldm add-vdsdev /dev/dsk/
c0t600601605A203100A44CDC74C082E211d0s2 vol2@primary-vds0
ldm add-vdisk vdisk0 vol2@primary-vds0 myldom
ldm bind myldom
ldm set-var auto-boot?=true myldom
 ldm start-domain myldom