#!/bin/bash
set -e
for i in $(seq 1 100); do
#Creating interface for the zone
dladm create-vnic -l e1000g1 hnet$i
#Creating initial config
TEMPFILE=$(mktemp /tmp/XXXXXXXXXXXXXXXXXX)
cat > $TEMPFILE <<EOF
create -b
set zonepath=/zones/h$i
set autoboot=true
set ip-type=exclusive
add net
set physical=hnet$i
end
add capped-memory
set physical=2G
end
add rctl
set name=zone.max-swap
add value (priv=privileged,limit=2147483648,action=deny)
end
add rctl
set name=zone.max-locked-memory
add value (priv=privileged,limit=536870912,action=deny)
end
EOF
zonecfg -z h$i -f $TEMPFILE
zfs send -R data/zones/h0@initial | zfs recv -F data/zones/h$i
# Zone tools should know that zone is in installed state, not configured
# Also during installation zoneadm assigns uuid to zone (last field). We do this manually.
uuid=$(uuidgen)
gsed -i -e "/^h${i}:/ s/\$/${uuid}/" -e "/^h${i}:/ s/configured/installed/" /etc/zones/index
zoneadm -z h$i mount
# We known that golden image ip address ends in 254 and change it
addr=$((1+$i))
sed -i -e "s:hnet0:hnet$i:g" -e "s:\.254:.$addr:g" /zones/h$i/root/etc/ipadm/ipadm.conf
zoneadm -z h$i unmount
zfs destroy data/zones/h$i@initial
rm $TEMPFILE
zoneadm -z h$i boot
done
четверг, 30 августа 2018 г.
Quest: creating one hundred zones
суббота, 10 февраля 2018 г.
A brief story of how you shouldn't promote your open source project
четверг, 1 февраля 2018 г.
пятница, 13 октября 2017 г.
Does ip belong to network?
#!/bin/sh
belongs_network ()
{
addr=$1
network=$2
netaddr=`echo $network | cut -d / -f 1`
netcdr=`echo $network | cut -d / -f 2`
a1=$(echo "$addr" | cut -d . -f 1)
a2=$(echo "$addr" | cut -d . -f 2)
a3=$(echo "$addr" | cut -d . -f 3)
a4=$(echo "$addr" | cut -d . -f 4)
n1=$(echo "$netaddr" | cut -d . -f 1)
n2=$(echo "$netaddr" | cut -d . -f 2)
n3=$(echo "$netaddr" | cut -d . -f 3)
n4=$(echo "$netaddr" | cut -d . -f 4)
ares=$((($a1*256*256*256+$a2*256*256+$a3*256+$a4)>>(32-$netcdr)))
nres=$((($n1*256*256*256+$n2*256*256+$n3*256+$n4)>>(32-$netcdr)))
if [ $ares -eq $nres ] ; then
return 0
else
return 1
fi
}
if belongs_network 10.208.103.255 10.208.128.0/17; then
echo "belongs"
else
echo "does not belong"
fi
среда, 29 марта 2017 г.
Thank you, Oracle engineers
- Our userland build system, which constantly evolves, however, in different directions, under Oracle control and in our distribution. But still a lot of components can be easily migrated between build systems.
- A lot of software build receipts and patches, as result, were borrowed with small modifications, from Oracle userland-gate. The process is still going on.
- We still borrow patches from Solaris pkg-gate. Also differences in underlying kernels are currently rather significant, a lot of changesets from pkg-gate can be ported to OpenIndiana pkg5 repository.
- Of course, I can not avoid thanking Alan for his constant help in supporting Xorg subsystem and GUI parts of our distribution. He was always helpful to me and Aurélien.
- Evidently, recent KMS work, integrated into OpenIndiana, wouldn't be possible without Oracle's open drm port, which was ported from Solaris to illumos by Martin Bochnig, and later independently ported and enhanced by Gordon Ross.
четверг, 16 февраля 2017 г.
Enterprise Information systems
пятница, 21 октября 2016 г.
Sending SMS notifications from OpenIndiana zone with Huawei E1550
I want to receive SMS notifications when something is terribly wrong in our data center. One part of the problem is OpenNMS, and we know how to configure it. But another part is actually sending SMS.
As only physical server with normal USB ports which we have is self-assembled SuperMicro storage, running OpenIndiana, we want to create OI zone, which can send SMS. First of all, we'll need some USB modem. I use Huawei e1550, which was already switched to modem-only mode (AT^U2DIAG=0) on Windows PC. Let's look at prtconf -v (looking for HUAWEI):
device, instance #0
Driver properties:
name='pm-components' type=string items=3 dev=none
value='NAME= usbsacm0 Power' + '0=USB D3 State' + '3=USB D0 State'
Hardware properties:
name='driver-minor' type=int items=1
value=00000000
name='driver-major' type=int items=1
value=00000002
name='high-speed' type=boolean
name='configuration#' type=int items=1
value=00000001
name='usb-product-name' type=string items=1
value='HUAWEI Mobile'
name='usb-vendor-name' type=string items=1
value='HUAWEI Technology'
name='usb-raw-cfg-descriptors' type=byte items=85
value=09.02.55.00.03.01.03.e0.fa.09.04.00.00.03.ff.ff.ff.00.07.05.81.03.40.00.05.07.05.82.02.00.02.20.07.05.01.02.00.02.20.09.04.01.00.02.ff.ff.ff.00.07.05.83.02.00.02.20.07.05.02.02.00.02.20.09.04.02.00.02.ff.ff.ff.00.07.05.84.02.00.02.20.07.05.03.02.00.02.20
name='usb-dev-descriptor' type=byte items=18
value=12.01.00.02.00.00.00.40.d1.12.01.10.00.00.02.01.00.01
name='usb-release' type=int items=1
value=00000200
name='usb-num-configs' type=int items=1
value=00000001
name='usb-revision-id' type=int items=1
value=00000000
name='usb-product-id' type=int items=1
value=00001001
name='usb-vendor-id' type=int items=1
value=000012d1
name='compatible' type=string items=3
value='usb12d1,1001.0' + 'usb12d1,1001' + 'usb,device'
name='reg' type=int items=1
value=00000006
name='assigned-address' type=int items=1
value=00000003
If modem was switched to modem-only mode, you'll see
value='usb12d1,1001.0' + 'usb12d1,1001' + 'usb,device'in 'compatible' field.So, let's say OI that it should use usbsacm to talk to it:
# update_drv -a -i 'usb12d1,1001' usbsacm
Now you should have /dev/term/0 - 3 devices and can use tip to talk to /dev/term/0:
# tip /dev/term/0 connected AT OK ~^D
Let's create zone and pass /dev/term/0 to the zone:
# zonecfg -z sms1 sms1: No such zone configured Use 'create' to begin configuring a new zone. zonecfg:sms1> create zonecfg:sms1> set zonepath=/zones/sms1 zonecfg:sms1> set brand=ipkg zonecfg:sms1> set autoboot=true zonecfg:sms1> set ip-type=exclusive zonecfg:sms1> add net zonecfg:sms1:net> set physical=sms10 zonecfg:sms1:net> end zonecfg:sms1> add device zonecfg:sms1:device> set match=/dev/term/0 zonecfg:sms1:device> end zonecfg:sms1> exit # zfs create data0/zones/sms1 # zoneadm -z sms1 install # zoneadm -z sms1 boot
Now we can configure network in our zone:
# zlogin sms1 # ipadm create-if sms10 # ipadm create-addr -T static -alocal=192.168.1.2/24 sms10/v4 # route add -p -net 0 192.168.1.1 # cp /etc/nsswitch.dns /etc/nsswitch.conf # echo 'nameserver 8.8.8.8' > /etc/resolv.conf # svcadm enable dns/client
We'll use gammu utilities to send sms:
# pkg install utility/gammu
Your /etc/gammurc (or ~/.gammurc) should look like:
[gammu] device = /dev/term/0 connection = at
If everything is fine, now you can send SMS:
# gammu sendsms TEXT +7myphone -text "test"