Nov 28, 2017

install archipel ubuntu

NOTE:
bold is important

1. setup hostname
hostname icloud.blackonsole.org
echo icloud.blackonsole.org > /etc/hostname


2. install some packages
apt-get install -y git ejabberd build-essential qemu-kvm libvirt-bin libvirt-dev python-setuptools python-numpy python-imaging python-apscheduler python-sqlalchemy python-libvirt subversion python-dev vim python-magic

3. edit : vim /etc/ejabberd/ejabberd.yml  (please check, sometimes the name is ejabberd.CFG)
if you are still use .cfg, you need to change with other source ejabberd.

echo "deb https://apt.jabber.at trusty ejabberd" > /etc/apt/sources.list.d/jabber.at.list
wget -qO- https://apt.jabber.at/gpg-key | apt-key add -
apt-get update
apt-get install -y git ejabberd



###
###             ejabberd configuration file
###         Archipel Sample default condiguration

###     =========
###     DEBUGGING

# Increase this if you want sone insane erlang debug
loglevel: 3

###     ================
###     SERVED HOSTNAMES

# Change it for you icloud.blackonsole.org
hosts:
    - "icloud.blackonsole.org"

###     ===============
###     LISTENING PORTS

listen:
    -
      #it's a good idea to put xmlrpc behing a reverse proxy
      #because you can't use tls directly, make it listen to localhost
      #ip : 127.0.0.1
      # and read the Security section on the wiki
      port: 4560
      module: ejabberd_xmlrpc
      access_commands:
            xmlrpcaccess:
                all : []

## ejabberd c2s
    -
      port: 5222
      module: ejabberd_c2s
      ##
      ## If you installed a SSL
      ## certificate, specify the full path to the
      ## file and uncomment this line:
      ##
      ## certfile: "/etc/ejabberd/ejabberd.pem"
      ## starttls: true
      max_stanza_size: 65536000
      shaper: c2s_shaper
      access: c2s

## ejabbed s2s
    -
      port: 5269
      module: ejabberd_s2s_in
      max_stanza_size: 65536000

## ejabberd http/s and websocket/s
    -
      port: 5280
      module: ejabberd_http
      request_handlers:
        "/xmpp": ejabberd_http_ws
      # if you want to use starttls with websock
      # the URI will be wss://
      # please be sure that the certificate belong
      # to a trusted AC in your browser
      # certfile: "/etc/ejabberd/ejabberd.pem"
      # tls: true
      web_admin: true
      http_bind: true

###     ===
###     S2S
s2s_policy: s2s_access
s2s_use_starttls: optional
#s2s_certfile: "/etc/ejabberd/ejabberd.pem"

## domain_certfile: Specify a different certificate for each served hostname.
##
## host_config:
##   "example.org":
##     domain_certfile: "/path/to/example_org.pem"
##   "example.com":
##     domain_certfile: "/path/to/example_com.pem"

###     ==============
###     AUTHENTICATION

auth_method: internal

###     ===============
###     TRAFFIC SHAPERS

shaper:
  # in B/s
  normal: 1000
  fast: 50000000

###     ====================
###     ACCESS CONTROL LISTS

acl:
    admin:
        user:
            - "admin": "icloud.blackonsole.org"
    local:
        user_regexp: ""


###     ============
###     ACCESS RULES

access:
    max_user_sessions:
        all: 10
    local:
        local: allow
    c2s:
        blocked: deny
        all: allow
    c2s_shaper:
        admin: none
        all: fast
    s2s_shaper:
        all: fast
    s2s_access:
        all: allow
    announce:
        admin: allow
    configure:
        admin: allow
    muc_admin:
        admin: allow
    muc_create:
        local: allow
    muc:
        all: allow
    pubsub_createnode:
        all: allow
    register:
        all: allow
    xmlrpcaccess:
        admin : allow

### Frequency of account registration
registration_timeout: infinity

###     ================
###     DEFAULT LANGUAGE

language: "en"

###     =======
###     MODULES

modules:
    mod_adhoc: []
    mod_announce:
        access: announce
    mod_caps: []
    mod_configure: []
    mod_disco: []
    mod_http_bind:
        max_inactivity: 400 # timeout valie for BOSH usefull for a large number of VM
    mod_irc: []
    mod_last: []
    mod_muc:
        access: muc
        access_create: muc_create
        access_persistent: muc_create
        access_admin: muc_admin
    mod_offline: []
    mod_privacy: []
    mod_private: []
    mod_pubsub:
        access_createnode: pubsub_createnode
        ignore_pep_from_offline: true
        last_item_cache: false
        max_items_node: 1000
        plugins:
            - "flat"
            - "hometree"
            - "pep"
    mod_register:
        access: register
    mod_roster: []
    mod_shared_roster: []
    mod_time: []
    mod_vcard: []
    mod_version: []
    mod_admin_extra: []

4. restart ejaberd
/etc/init.d/ejabberd restart

5. install archipel agent
cd /usr/local/src
git clone https://github.com/ArchipelProject/Archipel.git
cd Archipel
./pull.sh
easy_install apscheduler sqlalchemy numpy
cd ArchipelAgent
./buildAgent -d
archipel-initinstall


6. edit apparmor privileges 
Add "m" to /etc/apparmor.d/usr.sbin.ejabberdctl's "su" subprofile on /bin/su line:
                /bin/su rm,

7. register user

ejabberdctl register admin icloud.blackonsole.org 4dMinPassWD
archipel-tagnode -j admin@icloud.blackonsole.org -p 4dMinPassWD --create
archipel-rolesnode -j admin@icloud.blackonsole.org -p 4dMinPassWD --create
archipel-adminaccounts -j admin@icloud.blackonsole.org -p 4dMinPassWD --create

8. set agent
vim /etc/archipel/archipel.conf


#
# archipel.conf
#
# Copyright (C) 2010 Antoine Mercadal <antoine.mercadal@inframonde.eu>
#               2014 Cyril Peponnet <cyril@peponnet.fr>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <//www.gnu.org/licenses/>.


###############################################################################
###############################################################################

#
# General configuration. You should just need to edit these values
#
[DEFAULT]

# the default XMPP server to user
xmpp_server                 = icloud.blackonsole.org

# archipel's data folder
archipel_folder_lib         = /var/lib/archipel/

# this UUID will be used to identify the hypervisor
# internally. It MUST be different foreach one over
# your platform. You can generate a new one using
# uuidgen command
archipel_general_uuid       = b01ae4ae-0497-4356-b958-daHQ223B4jqJ

# the base working folder, where virtual machine related
# stuff will be stored
archipel_folder_data        = /vm/



###############################################################################
###############################################################################

#
# This is the main configuration parameters
#
[GLOBAL]

# jid of the xmpp pubsub server
xmpp_pubsub_server          = pubsub.%(xmpp_server)s

# jids of the root administrator separated with spaces
archipel_root_admins        = admin@%(xmpp_server)s tox@%(xmpp_server)s

# the ip of this machine. It can be :
# - auto : the IP if found using a Internet request.
# - gateway_interface : Using ip address configured on default gateway interface
# - X.X.X.X : manual ip
machine_ip                  = 1.2.3.4

# if set to True, XMPP layer uses avatars
use_avatar                  = True

# Folder of the avatars
machine_avatar_directory    = %(archipel_folder_lib)s/avatars

# the uri of hypervisor
libvirt_uri                 = qemu:///system

# [OPTIONAL] if set, this parameter is send to other hypervisors as migration UI
# migration_uri               = qemu+ssh://mydomain/system

# path were modules configuration are stored (*.conf)
modules_configuration_path = /etc/archipel/modules.d/

# default loading module policy
# - permissive : if no entry are found in the conf file in section MODULES, the module will be loaded anyway
# - restrictive: you need to explicitely declare what modules to load in MODULES
module_loading_policy       = restrictive

# [OPTIONAL] This parameters makes Archipel able to run in stateless mode.
# stateless mode needs some kernel parameters. please read the documentation (which is not available now :)
# about it, or leave it set to False
stateless_node              = False

#
# VCARD information - They CANNOT be empty
#
[VCARD]
orgname     = Archipel Corp
orgunit     = Dev
userid      = contact@archipelproject.org
locality    = San Francisco
url         = //archipelproject.org
categories  = Archipel


#
# The hypervisor configuration
#
[HYPERVISOR]

# the JID of this hypervisor. It MUST be different foreach one over
# your platform.
# If this account not exists, it will be created on the fly
hypervisor_xmpp_jid         = icloud@%(xmpp_server)s

# the XMPP password of this hypervisor
hypervisor_xmpp_password    = uFp97vJ7U6

# the vCard name of hypervisor. if set to "auto"
# the hostname is used
hypervisor_name             = auto

# the sqlite3 db file to store hypervisor informations
hypervisor_database_path    = %(archipel_folder_lib)s/hypervisor.sqlite3

# the default avatar to use for hypervisor, relative to
# GLOBAL:machine_avatar_directory and if GLOBAL:use_avatar is set to True
hypervisor_default_avatar   = defaulthypervisor.png

# the file contaning auto generated names for virtual machine creation
# must be a text file containing one name per line
name_generation_file        = %(archipel_folder_lib)s/names.txt

# the database file for storing permissions (full path required)
hypervisor_permissions_database_path = %(archipel_folder_lib)s/permissions.sqlite3

#
# The virtual machines configuration
#
[VIRTUALMACHINE]

# the base folder to use to store virtual machine's own
# informations (drives, etc...)
vm_base_path                    = %(archipel_folder_data)s/drives

# [OPTIONAL] the base folder to store virtual machine permissions
# if not set, permissions are stored in the base folder
# vm_perm_path                    = %(archipel_folder_data)s/drives

# the default avatar to use for virtual machine, relative to
# GLOBAL:machine_avatar_directory and if GLOBAL:use_avatar is set to True
vm_default_avatar               = defaultvm.png

# the size of the random generated XMPP password
xmpp_password_size              = 32

# the maximum lifetime of a lock (in seconds)
maximum_lock_time               = 1

# the database file for storing permissions (relative path required)
vm_permissions_database_path    = /permissions.sqlite3

# if set to false, all space in virtual machine names will be replaced by a '-'
# note that for xen backend this option has no effect as xen does'nt handle spaces in names.
allow_blank_space_in_vm_name    = True

# [OPTIONAL] this will allow to block access to block devices
# when defining virtual machines
enable_block_device_access      = True

# [OPTIONAL] this will disable the screenshot feature. Libvirt 0.9.5+ is bugged
# If you use these versions, set this value to True. Default value (i.e not set) is False
disable_screenshot              = False



#
# Logging configuration
#
[LOGGING]

# minimal log level. it can be in order:
# - debug
# - info
# - warning
# - error
# - critical
logging_level               = debug

# max life time of a log node in the pubsub
log_pubsub_item_expire      = 3600

# max number of stored log in the pubsub log node
log_pubsub_max_items        = 1000

# the path of file to store logs
logging_file_path           = /var/log/archipel/archipel.log

# max size in bytes of a log file before rotation
logging_max_bytes           = 5000000

# number of log backup file to keep
logging_backup_count        = 5

# the date format to use in log file.
# See //docs.python.org/library/logging.html#formatter-objects
logging_date_format         = %Y-%m-%d %H:%M:%S

# the log format to use in log file.
# See //docs.python.org/library/datetime.html?highlight=date#strftime-and-strptime-behavior
logging_formatter           = %(levelname)s::%(asctime)s.%(msecs)03d::%(filename)s:%(lineno)s::%(message)s

# If this is True, xmpppy will be in debug mode
xmpppy_debug                = False

[MODULES]

action_scheduler            = True
centraldb                   = True
geolocalization             = True
hypervisor_health           = True
hypervisor_network          = True
hypervisor_vmcasts          = True
iphone_notification         = False
oomkiller                   = True
snapshoting                 = True
storage                     = True
virtualmachine_appliance    = True
vnc                         = True
xmppserver                  = True
vmparking                   = True  # needs centraldb to be activated

[CENTRALAGENT]
# centralagent can be :
#  - auto (default) : will be central agent if there is none already started
#  - force : will be central agent (be careful to configure only one of your hypervisors this way)
centralagent               = auto

[VNC]
vnc_certificate_file                        = None
vnc_only_ssl                                = False
vnc_enable_websocket_debug                  = True

10. restart archipel
/etc/init.d/archipel restart

11. adding iso
mkdir /vm/iso/
chmod 777 /vm/iso
cd /vm/iso
wget //de.releases.ubuntu.com/14.04.3/ubuntu-14.04.3-server-amd64.iso


12. install client 

wget //nightlies.archipelproject.org/latest-archipel-client.tar.gz
tar -xzf latest-archipel-client.tar.gz
cd Archipel/
python -m SimpleHTTPServer


13. Play with Archipel Client
Open //localhost:8000 in web browser.
0. Log in with admin@ user in installation
1. Add contact and then add icloud@icloud.blackonsole.org
2. Create VM in Archipel VMs
3. Configure hdd, cdrom, Nic for VM
4. Run the VM


in some distro, you need to set user on sudo vim /etc/libvirt/qemu.conf  



refs :
0. https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/599910  
1. https://blackonsole.org/how-to-install-archipel-on-linux-ubuntu/
2. https://bugs.launchpad.net/ubuntu/+source/ejabberd/+bug/1659801 
3. https://www.digitalocean.com/community/tutorials/how-to-install-ejabberd-xmpp-server-on-ubuntu
Read more ...

Nov 14, 2017

android yowsup get password registration and login


edit android env

sudo vim /usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/env/env_android.py

class AndroidYowsupEnv(YowsupEnv):
    _SIGNATURE = "MIIDMjCCAvCgAwIBAgIETCU2pDALBgcqhkjOOAQDBQAwfDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFDASBgNV" \
        "BAcTC1NhbnRhIENsYXJhMRYwFAYDVQQKEw1XaGF0c0FwcCBJbmMuMRQwEgYDVQQLEwtFbmdpbmVlcmluZzEUMBIGA1UEAxMLQnJ" \
        "pYW4gQWN0b24wHhcNMTAwNjI1MjMwNzE2WhcNNDQwMjE1MjMwNzE2WjB8MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5" \
        "pYTEUMBIGA1UEBxMLU2FudGEgQ2xhcmExFjAUBgNVBAoTDVdoYXRzQXBwIEluYy4xFDASBgNVBAsTC0VuZ2luZWVyaW5nMRQwEg" \
        "YDVQQDEwtCcmlhbiBBY3RvbjCCAbgwggEsBgcqhkjOOAQBMIIBHwKBgQD9f1OBHXUSKVLfSpwu7OTn9hG3UjzvRADDHj+AtlEm" \
        "aUVdQCJR+1k9jVj6v8X1ujD2y5tVbNeBO4AdNG/yZmC3a5lQpaSfn+gEexAiwk+7qdf+t8Yb+DtX58aophUPBPuD9tPFHsMCN" \
        "VQTWhaRMvZ1864rYdcq7/IiAxmd0UgBxwIVAJdgUI8VIwvMspK5gqLrhAvwWBz1AoGBAPfhoIXWmz3ey7yrXDa4V7l5lK+7+jr" \
        "qgvlXTAs9B4JnUVlXjrrUWU/mcQcQgYC0SRZxI+hMKBYTt88JMozIpuE8FnqLVHyNKOCjrh4rs6Z1kW6jfwv6ITVi8ftiegEkO" \
        "8yk8b6oUZCJqIPf4VrlnwaSi2ZegHtVJWQBTDv+z0kqA4GFAAKBgQDRGYtLgWh7zyRtQainJfCpiaUbzjJuhMgo4fVWZIvXHaS" \
        "HBU1t5w//S0lDK2hiqkj8KpMWGywVov9eZxZy37V26dEqr/c2m5qZ0E+ynSu7sqUD7kGx/zeIcGT0H+KAVgkGNQCo5Uc0koLRW" \
        "YHNtYoIvt5R3X6YZylbPftF/8ayWTALBgcqhkjOOAQDBQADLwAwLAIUAKYCp0d6z4QQdyN74JDfQ2WCyi8CFDUM4CaNB+ceVXd" \
        "KtOrNTQcc0e+t"

    _MD5_CLASSES = "3jYxFPSrhqjabEm5b2sXhA==" # ry9Xz6kVioQctwA3G9z62Q=="
    _KEY = "eQV5aq/Cg63Gsq1sshN9T3gh+UUp0wIw0xgHYT1bnCjEqOJQKCRrWxdAe2yvsDeCJL+Y4G3PRD2HUF7oUgiGo8vGlNJOaux26k+A2F3hj8A=" #eQV5aq/Cg63Gsq1sshN9T3gh+UUp0wIw0xgHYT1bnCjEqOJQKCRrWxdAe2yvsDeCJL+Y4G3PRD2HUF7oUgiGo8vGlNJOaux26k+A2F3hj8A="

    _VERSION = "2.17.279" #2.12.556"
    _OS_NAME = "Android"
    _OS_VERSION = "4.3"
    _DEVICE_NAME = "armani"
    _MANUFACTURER = "Xiaomi"
    _BUILD_VERSION = "JLS36C"

    _AXOLOTL = True



request register :
yowsup-cli registration --requestcode sms -m 504 -n 01 --phone 6285xxx --cc 62 --mcc 510 --mnc 852 --env android

yowsup-cli  v2.0.15
yowsup      v2.5.2

Copyright (c) 2012-2016 Tarek Galal
http://www.openwhatsapp.org

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://openwhatsapp.org/yowsup/donate


INFO:yowsup.common.http.warequest:b'{"login":"6285xxx","status":"sent","length":6,"method":"sms","retry_after":65,"sms_wait":65,"voice_wait":65}\n'
status: b'sent'
retry_after: 65
length: 6
method: b'sms'
login: b'6285xxx'


register :
yowsup-cli registration --register 535-804 -m 504 -n 01 --phone 6285xxx --cc 62 --mcc 510 --mnc 852 --env android

yowsup-cli  v2.0.15
yowsup      v2.5.2

Copyright (c) 2012-2016 Tarek Galal
http://www.openwhatsapp.org

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://openwhatsapp.org/yowsup/donate


INFO:yowsup.common.http.warequest:b'{"status":"ok","login":"6285xxx","type":"existing","pw":"NSFit709bWoiXstG8CS3N18yZ8E=","expiration":4444444444.0,"kind":"free","price":"$0.99","cost":"0.99","currency":"USD","price_expiration":1511231163}\n'
login: b'6285xxx'
kind: b'free'
status: b'ok'
price_expiration: 1511231163
expiration: 4444444444.0
currency: b'USD'
pw: b'NSFit709bWoiXstG8CS3N18yZ8E='
price: b'$0.99'
type: b'existing'
cost: b'0.99'

you can login and send WA message via command line then.


Read more ...

SOLVED metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases


THE PROBLEM IS :

Traceback (most recent call last):
  File "./yowsup-cli", line 6, in <module>
    from yowsup.env import YowsupEnv
  File "/home/XXX/dunia_wa/yowsup/baru/yowsup-master/yowsup/env/__init__.py", line 1, in <module>
    from .env import YowsupEnv
  File "/home/XXX/dunia_wa/yowsup/baru/yowsup-master/yowsup/env/env.py", line 15, in <module>
    class YowsupEnv(with_metaclass(YowsupEnvType, object)):
  File "/usr/lib/python2.7/abc.py", line 87, in __new__
    cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases

    metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

THE SOLUTION IS :
 sudo pip install six==1.10.0
Read more ...

Sep 27, 2017

setup odoo as service ubuntu 16.04

create file /lib/systemd/system/odoo-server.service

[Unit]
Description=Odoo Open Source ERP and CRM
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
PermissionsStartOnly=true
SyslogIdentifier=odoo-server
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo-10.0/odoo-bin --config=/etc/odoo.conf --addons-path=/opt/odoo/odoo-10.0/addons/
WorkingDirectory=/opt/odoo/odoo-10.0/
StandardOutput=journal+console

[Install]

WantedBy=multi-user.target


change ownership
sudo chmod 755 /lib/systemd/system/odoo-server.service
sudo chown root: /lib/systemd/system/odoo-server.service
sudo chown -R odoo: /opt/odoo/
sudo chown odoo:root /var/log/odoo
sudo chown odoo: /etc/odoo.conf
sudo chmod 640 /etc/odoo.conf

enable the service 
sudo systemctl enable odoo-server

start the service 
sudo systemctl start odoo-server

taken from : 
https://www.linode.com/docs/websites/cms/install-odoo-10-on-ubuntu-16-04#create-an-odoo-service 

NOTE : 
if you change odoo-server.service, you need to run 
sudo systemctl daemon-reload
Read more ...