openSUSE for Raspberry Pi 3 をためしてみた – ながいものには、まかれたくない

openSUSE for Raspberry Pi 3 をためしてみた – ながいものには、まかれたくない

いつの間にかリリースされていたようです。

openSUSEというのはドイツのLinuxディストリビューションSUSE Enterprise Linux Server のコミュニティ版です。

RedhatにおけるFedoraに近いイメージでいいのでしょうか。Fedoraよりは安定志向と思いますが。

昨年11月ごろにARM向けのリリースが告知(というか、以前にも対応していたものの、最新版は未提供だった?)が出ていたもの。

HCL:Raspberry Pi3 – openSUSE

何が嬉しいかというと、64ビットモードで動作するという点です。ラズパイ3のCPUはCortex-A53(ARMv8アーキテクチャ)で、ハードウェア的には64 bitモードをサポートしていますが 、公式のOSとしては32ビットのカーネルしか提供されていませんでした。

今回のopenSUSEは非公式のOSイメージを使うとか、もしくは自前でカーネル一式ビルドするという面倒なことをしなくても64bitモードで動くよってのが一番のポイントです。

f:id:atuyosi:20170203014729p:plain

  • 準備
    • OSイメージのバリエーションについて
    • ファイルのチェック
    • microSDへのデータ書き込み
  • インストール後の諸設定
    • 初回起動時の挙動
    • 色々
    • XFce の設定
    • そのほか
  • まとめ

準備

前提はRaspberry Pi 3 model B、64ビットモードで動作する方のOSイメージ、です。

OSイメージのバリエーションについて

安定版であるopenSUSE Leap 44.2と、ローリングリリスース版である openSUSE Tumbleweedの2つのバージョンがあり、さらにローリングリリスース版には無印のTumbleweed とTumbleweed (non-upstream) で合計3系統。

デスクトップ環境の違いによりトータル14パターンのディスクイメージが提供されているようです。

non-upstreamというのは意味がよくわかりません。普通、OSSでupstreamというのは特定コンポーネントのオリジナルの開発元のことを指すと思うのですが、SUSEにupstreamと言われてもさっぱりです。 CentOSでupstreamといえばRedHatRHELだったりしますが。

カーネルSUSE標準のものか、Raspberry 用のカスタム版かのことを言っているのでしょうか?

※ Leapの方のLXQt版は提供されていないようです。ダイレクトリンクは404 Not Foundになっていますし、general download directoryとやらをチェックしても存在しないようです。

FTPからダウンロードする場合はファイル名がraspberrypi3.aarch64.raw.xzのものと、efi.aarch64.raw.xzのものがあるので要注意です。

42.2 Leap、Tumbleweed、Tumbleweed (non-upstream ) のそれぞれ3系統試しましたが、私の環境ではTumbleweed (non-upstream )以外は正常に動作しませんでした。

42.2 Leap に関してはログインプロンプトが表示されるにもかかわらず自動的にGUIに切り替わるタイミングでフリーズ。一方、無印のTumbleweedは起動自体は成功しますが、GUIの起動に失敗してフリーズして使い物にならないです*1

手持ちのmicroSD 3種類で試してダメだったので、microSDとの相性ではなさそうです。HDMIモニタのせいなのか、ググっても情報がないので諦めモードです。

Tumbleweed (non-upstream )については初回起動時は途中でフリーズしますが、電源オフして再度電源を投入すると起動できました。最初はLXQt 環境で行きたかったのですが、スクリーンショットが取れなかったのでXFceに切り替え。

上記リンク先の、”Installing the 64-bit non-upstream openSUSE Tumbleweed image”という見出しの下にある”XFCE image”からダウンロード。

ファイルのチェック

Linux (Raspbian)で作業しています。macOSの場合はddコマンドのオプションに注意。余計なオプションなしでRaspbianと同様にすればいけるはずです。

まずはダウンロードしたファイルのSHAチェックサムが一致するか確認。チェックサムの記載されたファイルを入手。以下は42.2 Leap の例。

$ get http://download.opensuse.org/repositories/devel:/ARM:/Factory:/Contrib:/RaspberryPi3/images/openSUSE-Tumbleweed-ARM-XFCE-raspberrypi3.aarch64-2017.01.28-Build4.3.raw.xz.sha256   <skip>  $ cat openSUSE-Tumbleweed-ARM-XFCE-raspberrypi3.aarch64-2017.01.28-Build4.3.raw.xz.sha256   <skip>  $  sha256sum openSUSE-Tumbleweed-ARM-XFCE-raspberrypi3.aarch64-2017.01.28-Build4.3.raw.xz   <skip>

目視で比較はスマートではないという場合は、*.sha256ファイルとチェック対象が同一ディレクトリに存在するものとして*2下記を実行する。「完了」と表示されていれば問題なし(2行目)。警告が出ているのはチェックサムを記録しているファイルに署名がくっついているためだと思う。

$ sha256sum -c openSUSE-Tumbleweed-ARM-XFCE-raspberrypi3.aarch64-2017.01.28-Build4.3.raw.xz.sha256  openSUSE-Tumbleweed-ARM-XFCE-raspberrypi3.aarch64-2017.01.28-Build4.3.raw.xz: 完了  sha256sum: 警告: 書式が不適切な行が 14 行あります

なお、mac環境ではsha256sumじゃなくてshasumコマンドを使う。

$ shasum -a 256 openSUSE-Leap42.2-ARM-XFCE-raspberrypi3.aarch64-2017.01.20-Build1.1.raw.xz

*.sha256ファイルに記載のチェックサムと一致していればOK。よりスマートにやるなら-cオプションを使う。

$ shasum -a 256 -c openSUSE-Leap42.2-ARM-XFCE-raspberrypi3.aarch64-2017.01.20-Build1.1.raw.xz.sha256  openSUSE-Leap42.2-ARM-XFCE-raspberrypi3.aarch64-2017.01.20-Build1.1.raw.xz: OK  shasum: WARNING: 14 lines are improperly formatted

配布元のサイトの、対応するファイルに記載されているチェックサムと一致すればダウンロード成功。

定期的にファイルが更新されるようなのでファイル名に含まれる日付部分はダウンロードしたファイルに合わせて変更する必要あり。

microSDへのデータ書き込み

USB接続のカードリーダーをラズパイにつないで作業。microSDをセットすると勝手にマウントされるのでまずはマウント解除。

まず確実に対象デバイスをマウント解除。XXXはマウントポイント名。

$ sudo amount /media/pi/XXX

対象ファイルをddで書き込み。ラズパイ以外の環境で/dev/sdaはルートパーティションなので注意。

バイス名はdmesg | grep sdmountの出力を確認すれば特定できるはず。

$ xzcat openSUSE-Tumbleweed-ARM-XFCE-raspberrypi3.aarch64-2017.01.28-Build4.3.raw.xz | sudo dd bs=4M of=/dev/sda iflag=fullblock oflag=direct;  sync   906+0 レコード入力  906+0 レコード出力  3800039424 バイト (3.8 GB) コピーされました、 506.372 秒、 7.5 MB/秒

macOSでは4M4mに、デバイス名にiflagoflagは外す。またデバイス名も/dev/rdiskNのようにrをつける。

私の環境では10分ぐらいでした。コーヒーでも紅茶でも飲んでのんびり待つだけ。

あとはmicroSDを取り出して、ラズパイ側に差し込んで電源ON。

f:id:atuyosi:20170203014649p:plain

インストール後の諸設定

初回起動時は普通にGUIの軌道にコケる。画面左上にアンダーバーが表示されてフリーズ。

電源をオフにして再度電源を入れるとしれっとログイン画面が表示される。

初期ユーザー名はrootでパスワードはlinuxというのがopenSUSEのデフォルトらしい。

デスクトップ環境さえ起動してしまえばあとはGUIのツールからユーザーを追加できる。

atuyosi@localhost:~> uname -a  Linux localhost.localdomain 4.4.44-8-default #1 SMP Mon Jan 30 06:03:56 UTC 2017 (345bd0b) aarch64 aarch64 aarch64 GNU/Linux

いいですね、このaarch64という文字列が見たかった。

ところでこのプロンプトは一体。

f:id:atuyosi:20170203030613p:plain

まあ別にいいけど。

初回起動時の挙動

初回起動時のみそれなりに時間がかかる。そしてフリーズする。

かなりやんちゃなことをやっている印象。三番目はかなり危険だと思うんですけど。

パーティションの拡張とかしてるせいで初回起動時にコケるのかなあと。

また、swapサイズはかなり小さかったはず。500MBぐらい。

色々

SUSEといえばGUIの管理ツールであるYast

画面左下の”openSUSE“というメニューから”Settings”をポイントして展開されるメニューから”Yast“。

f:id:atuyosi:20170203014706p:plain Yast から”Language”をクリックして”Primary Language” をJapanese にするだけ。プルダウンポックスの下のチェックボックスを有効にするとキーレイアウトも面倒を見てくれるはず。

f:id:atuyosi:20170203014626p:plain

f:id:atuyosi:20170203014809p:plain

初回は追加パッケージをインストールするようなので時間がかかる。再起動してログイン画面から言語とキーボード配列を日本語(ja_JP.UTF-8)にしてログインすればOK。

画面左下のメニューからYast を起動して、”Software Management”をクリックするとGUIでソフトウェアをインストールできる。

fcitx-mozcをインストールして一旦ログアウトしてログインし直せば、日本語も入力可能。

f:id:atuyosi:20170203020855p:plain

f:id:atuyosi:20170203021208p:plain

fcitx 自体の設定は他の環境と同じ。日本語キーボードとmozcを追加して英語キーボードを削除する。

XFce の設定

画面左下の”openSUSE“というメニューから”Settings”をポイントして”Settings Manager”。

デスクトップの外観などの細かい設定はこっちから。

そのほか

  • 画面解像度がおかしい(1824×984、変更不能?)
  • HDMIモニタのスピーカーが使えない
  • 無線LANはデバイスが見えていない?
  • 初期状態ではsshは起動していない(というか、sshのホストキーが正常に読み出せていない)
  • 初期状態では日本語入力用のソフトウェアはインストールされていない

まだベータ版なんでしょうか。そもそもユーザー数が少ないのかな。

まとめ

ベンチマークは面倒だし省略。体感速度は結局、microSDの性能次第だという印象です。

デバイスドライバ完備の Raspbian と比べると常用は厳しそう。Fedora 26に期待。

それではまた。

*1:日付が表示されるところでストップしてそこから進まない

*2:なおかつファイルのあるディレクトリに移動する

openSUSE for Raspberry Pi 3 をためしてみた – ながいものには、まかれたくない

KVM on the Raspberry Pi2 | A travelling tinker

KVM on the Raspberry Pi2 | A travelling tinker

In my last post I wrote about to getting my Pi2 to boot with HYP enabled on all 4 CPUs. The next stage is to get a kernel with KVM enabled and get a VM up and running. Once again most of this method is taken from a blog post by @sergiolpascual I have tidied it up and refined the method of using a single CPU core without patching QEMU.

Building a KVM enabled kernel for the Pi

First of all you need to get a KVM enabled kernel for the Pi2 host. These commands checkout the current 3.18 version of the Raspberry Pi foundation’s kernel tree and apply a pull request on top of it to enable GIC emulation.

git clone https://github.com/raspberrypi/linux  cd linux  git checkout rpi-3.18.y  git fetch origin pull/902/head:VGIC-emu  git checkout VGIC-emu

I started off with the same base config as the kernel on my Pi 2. There is a file /proc/config.gz that stores the config the running kernel was built with. Copy this file to your build host, uncompress it and rename it to /working/rpi2/.config that way you will only need to make a few minor changes to the config.

scp user@pi:/proc/config.gz /tmp/config.gz  mkdir -p /working/rpi2  zcat /tmp/config.gz > /working/rpi2/.config

Now we need to setup a cross compile environment again and start the kernel config system.

export ARCH=arm  export CROSS_COMPILE=arm-linux-gnueabihf-  make O=/working/rpi2 menuconfig  

I’ve listed the options that need to be changed to enable KVM support in the kernel, these notes are copied from @sergiolpascual‘s post. I have uploaded my KVM enabled config with these options set already.

Note the O= option this sets the directory where compiled parts of the kernel are put, it means that your source tree stay clean.

  • Patch physical to virtual translations at runtime
  • General setup -> Control Group support
  • System Type -> Support for Large Physical Address Extension
  • Boot options -> Use appended device tree blob to zImage (EXPERIMENTAL)
  • Boot options -> Supplement the appended DTB with traditional ATAG information
  • Virtualization -> Kernel-based Virtual Machine (KVM) support (NEW)
    • DISABLE Virtualization -> KVM support for Virtual GIC
    • ENABLE Virtualization -> KVM support for Emulated GIC

Now you just need to build the kernel and install the modules

make O=/working/rpi2 all -j 4  export INSTALL_MOD_PATH=/tmp/rpi-kernel  make O=/working/rpi2 modules_install

To build the Pi2 boot image, glue the kernel and DTB file together thus

cat /working/rpi2/arch/arm/boot/zImage /working/rpi2/arch/arm/boot/dts/bcm2709-rpi-2-b.dtb > /tmp/rpi-kernel/kernel7.img

Copy the directory /tmp/rpi-kernel to the Pi2, replace /boot/firmware/kernel7.img (take a backup first) with our new kernel and move the new 3.18.x modules directory to /lib/modules/.

You will need to adjust the Pi’s kernel command line to add “isolcpus=3” to work round a bug. To do this via u-boot run these commands from the u-boot command line:

setenv "${bootargs} isolcpus=3"  saveenv

A final reboot and you should get this in dmesg

dmesg | grep kvm  kvm [1]: timer IRQ99  kvm [1]: Hyp mode initialized successfully

Booting your first Virtual Machine

So long as you are running Debian / Raspbian Jessie then you can just run

apt-get install qemu-system

Adding the boot option isolcpus=3 works round an oddity of the Raspberry Pi’s CPU, discussed in more detail in the original blog post. We need to ensure that QEMU only runs on this isolated CPU. In the original post this was done by patching QEMU but there is a much easier way, taskset. Taskset allows us to restrict QEMU to only CPU 3 with
the “-c 3-3” option.

This is my basic run script to boot an ARM VM on the Raspberry Pi2. I used the Linaro prebuilt ARM kernels and root images to test with and have included the URLs in the script.

#!/bin/sh    # Disable the QEMU sound driver  export QEMU_AUDIO_DRV=none    # Basic system setup an ARM vexpress with 1 CPU, 256M of RAM  smp=1  cpu=host  ram=256  machine=vexpress-a15  # Where are the kernel and root images stored  dir=/root/linaro    # Source: https://snapshots.linaro.org/ubuntu/images/kvm/latest/zImage-armv7   kernel=$dir/zImage-armv7  # Source: https://snapshots.linaro.org/ubuntu/images/kvm/latest/vexpress-v2p-ca15-tc1.dtb   dtb=$dir/vexpress-v2p-ca15-tc1.dtb  # Source: http://snapshots.linaro.org/ubuntu/images/kvm-guest/36/armhf/kvm-armhf.qcow2.xz  rootfs=$dir/kvm-armhf.qcow2  # Virtual machine Linux command line  cmdline="root=/dev/vda2 rw mem=${ram}M console=ttyAMA0 rootwait rootfstype=ext4"    # Use taskset to ensure that QEMU only runs on cpu 3  taskset -c 3-3 qemu-system-arm -enable-kvm -smp $smp -m $ram -M $machine -cpu host -kernel $kernel -dtb $dtb -append "$cmdline" -drive if=none,id=rootfs,file=$rootfs -device virtio-blk-device,drive=rootfs -netdev user,id=user0 -device virtio-net-device,netdev=user0 -nographic
KVM on the Raspberry Pi2 | A travelling tinker

Setting up KVM on Raspberry Pi 3 using a 64bit openSUSE Pi3 Leap 42.2 xfce image

<base href="https://medium.com/@valdiz777/setting-up-kvm-on-raspberry-pi-3-using-a-64bit-opensuse-pi3-leap-42-2-xfce-image-22faddf02f48“>Setting up KVM on Raspberry Pi 3 using a 64bit openSUSE Pi3 Leap 42.2 xfce image

<img class=”progressiveMedia-noscript js-progressiveMedia-inner” src=”https://higeon.wordpress.com/wp-content/uploads/2017/11/9f862-1vxvtgm-ywezwbvbayu1v5q.jpeg“>
Obligatory Raspberry Pi 3 Model B Image

This story begins how most stories begin, browsing github issues and tech forums to hope that someone is going or has gone through the process of getting a working kvm virtualization on the Raspberry Pi 3. For me, things started looking good after I stumbled into this particular issues thread on github. That eventually led me to this post about the release of openSUSE Pi3 Leap 42.2 64bit image for the raspberry pi. If you are like me and have been searching le interwebs for this exact product this probably looked too good to be true but lo and behold here we are.

Without further ado, this is what I did to get kvm setup on my Raspberry Pi 3 model B:

# Download the opensuse 64bit image for raspberry pi 3

1. Download the opensuse Leap 42.2 xfce image from the HCL website here. This is the only 64 bit aarch image for the raspberry pi 3 right now…I tried about everything from ubuntu snappy to centos7 to le fedora but with no cigar. This OS image comes with the kvm kernel module automatically installed. NOTE: LVDS display (e.g. raspberry pi 7 inch display) won’t work with this image. If you don’t have an HDMI capable display close by, don’t worry because I manage to get a remote display working through remote desktop (xrdp) by leveraging this guide — I explain this later.

# Preparing the SD card.

2. I used Etcher to flash the 64bit xfce image to the SD card.

# Installing the image

3.1 Insert the SD card with the openSUSE image into your board.

3.2 Connect the board to your PC via HDMI or serial port (optional, but helpful for debugging; USB-TTL serial cable needed). I didn’t use this initially but I strongly recommend it so you can get insight into what’s going on asap… I kinda flew blind and crossed my fingers a lot when I got to the images without display support. Any HDMI version 1.3a and below are guaranteed to work. The serial port details should be either serial0 at 115200 or ttyAMA0 at 115200.

3.3 For an easy first connection, I recommend using Ethernet but if you’d like you can setup wifi through the serial port using by leveraging this guide.

3.4 Power on the board and walk through the boot process. If you are flying blind, I timed this process on my board and it took 5 minutes.

3.4.1 After this process is finished you can connect to the board using ssh if know what ip the board is running on. You can also login through the serial interface. The default login is root:linux, works on serial console, via ssh, or GUI. I connected using ssh to my raspberry pi running at 192.168.1.86.

ssh root@192.168.1.86

3.5 Update the package manager by running

sudo zypper update

If you have network issues related to ipv6 then edit the /proc/sys/net/ipv6/conf/all/disable_ipv6 file and change the value from 0 to 1.

# Installing xrdp to enable GUI through Remote Desktop

Part of the reason I chose the xfce image is so that I can easily setup remote desktop on my pi.

4.1 Open a terminal and run

sudo zypper install xrdp

<img class=”progressiveMedia-noscript js-progressiveMedia-inner” src=”https://higeon.wordpress.com/wp-content/uploads/2017/11/93be4-1mgvv0kb4rbhfuzxw24irkq.png“>

Then run

echo xfce4-session >~/.xsession

4.2 Restart the xrdp session.

sudo service xrdp restart

NB: You will have to do this everytime you reboot the board.

4.3 You can now use remote desktop on windows or Mac to connect to your pi.

<img class=”progressiveMedia-noscript js-progressiveMedia-inner” src=”https://higeon.wordpress.com/wp-content/uploads/2017/11/325af-1-o1jxiuxnhyky0th_guoma.png“>
This is what it looked like for me. My pi was running at 192.168.1.86. Password is linux.

After connecting you should then see a screen that looks like this

# Installing libvirt and virt-manager

<img class=”progressiveMedia-noscript js-progressiveMedia-inner” src=”https://higeon.wordpress.com/wp-content/uploads/2017/11/85ba9-16irinm8wcb1zeltkaissfa.png“>
KVM running on virt-manager

Like I said, this image already has kvm kernel modules enabled automatically. From here we will just install libvirt and virt-manager. Virt-manager makes it easy to create and manager guest virtual machines by providing a graphical interface.

5.1 Install qemu uefi support, libvirt, and virt-manager by running

sudo zypper install qemu-uefi-aarch64 libvirt virt-manager

5.2 Restart the libvirtd service by running

sudo service libvirtd restart

NB: again, you will have to do this everytime you reboot the board.

5.3 type virt-manager on the terminal to bring up the virt-manager

<img class=”progressiveMedia-noscript js-progressiveMedia-inner” src=”https://higeon.wordpress.com/wp-content/uploads/2017/11/11413-1zqugr5-hx6-m4yajwl-mlw.png“>
virt-manager kvm not yet connected.

5.4 Double click the QEMU/KVM selection to connect. If you see something that says that libvirtd daemon is not running then you need to restart the libvirtd service like I did above and try again. if not you should see the Not Connected status go away.

With that we have officially connect KVM to run on pi3. From here you can create a new virtual machine by going to File>New Virtual Machine. Doing that should produce a pop-up like the image at the title of this section. Follow the instructions and configure your VMs to run with KVM!

Hack happily,

VN

Setting up KVM on Raspberry Pi 3 using a 64bit openSUSE Pi3 Leap 42.2 xfce image

mOnionO – The mobile Onion Observer

by FISHERMAN

mOnionO is a mobile Onionoo client which can be used to search and display information about TorTM nodes. The client is based on the AndroidTM platform. mOnionO based on API-level 10.
Request for Test!
An initial test version ofmOnionOis available in the http://code.google.com/p/moniono/downloads/list’>Downloads section. We would like to ask as many of you as possible to download that version and install it on emulators or devices. Please send us your feedback to moniono@gmx.net no matter how intensively you tested the app! If you found any concrete bugs, please directly report them in the http://code.google.com/p/moniono/issues/list’>Issues section
The following screenshots will give you an impression of the provided functionalities:

Next Steps

The following list gives an overview of the concretely planned next steps: * Execution of test phase * Publication of mOnionO in AndroidTM market.

Future Plans

Depending on acceptance and feedback, the following topics might be considered for future releases: * Notification Service: Notification on favourite nodes becoming (un)available (up/down). * Find my Server: Integration with Google Maps. * State of the Network: Aggregation of statisics on network level, e.g., number of nodes (up/down). * …

Onionoo

The Onionoo project defines a protocol to request status information about nodes of the Tor network. This information is published through a web server being part of the Onionoo project. Information is distributed via HTTPS.
This project makes use of Onionoo information to allow administrators of Tor nodes or other people being interested in the Tor network to observe information on nodes directly from their mobile device. The core features provided by mOnionO are: * Search for relays based on their nicknames, IP addresses, and fingerprints. * Search for bridges based on fingerprint hashes. * Display all node information being provided by Onionoo. * Favorite nodes list. * History charts of bandwidth information.
The Onionoo project itself makes use of information on nodes being directly obtained from The Tor Project. For further information on Onionoo please refer to the project homepage.
Tor is a registered trademarkof The Tor Project, Inc., Android is a trademark of Google Inc.

from https://code.google.com/archive/p/moniono/

Shared via Inoreader

mOnionO – The mobile Onion Observer

CentOS安装OpenVZ并配置OpenVZ Web Panel – 主机百科

CentOS安装OpenVZ并配置OpenVZ Web Panel – 主机百科

注意:本教程的方法建立在基于KVM构架的VPS或独立服务器上。
前提准备:VPS或服务器安装CentOS 6及以上系统。update系统,并安装vim编辑器。

1、关闭selinux并配置iptables(重要)

vim /etc/sysconfig/selinux  

添加内容:

SELINUX=disabled  

保存。
开放iptables的3000端口:

/sbin/iptables -I INPUT -p tcp --dport 3000 -j ACCEPT  /etc/rc.d/init.d/iptables save  /etc/init.d/iptables restart  

2、安装OpenVZ

配置YUM源

安装OpenVZ内核和vzctl、vzquota等工具

yum install  vzkernel  yum install vzctl vzquota  

配置OS内核参数,进入/etc/sysctl.conf文件,修改下面两个参数

为了让VE访问外部网络,需要对IP进行转发

net.ipv4.ip_forward = 1  

主要是控制对kernel系统信息的debug功能

kernel.sysrq = 1  

使上面的配置文件生效

modprobe bridge  lsmod|grep bridge  

现在reboot,重启后检查VZ服务是否运行

chkconfig --list vz  

返回如下信息则代表正在运行

vz                0:off 1:off 2:on 3:on 4:on 5:on 6:off  

启动之前可以先检查一下OpenVZ服务时候已经启动了

service vz status   service vz start   

3、安装OpenVZ Web Panel

安装结束后,使用如下信息登录控制面板

4、添加hw-daemon.rb内容

vim /opt/ovz-web-panel/utils/hw-daemon/hw-daemon.rb  

添加如下内容:

#!/usr/bin/env ruby    require 'webrick'  require 'xmlrpc/server.rb'    # workaround for clients with incorrect DNS records  Socket.do_not_reverse_lookup = true    ENV['PATH'] += ':/usr/sbin'    DAEMON_VERSION = '1.3'  CURRENT_DIR = File.expand_path(File.dirname(__FILE__)) + '/'  CONFIG_FILE = CURRENT_DIR + 'hw-daemon.ini'  PID_FILE = CURRENT_DIR + 'hw-daemon.pid'  LOG_FILE = CURRENT_DIR + 'hw-daemon.log'  SSL_CERT_FILE = CURRENT_DIR + "/certs/server.crt"  SSL_PKEY_FILE = CURRENT_DIR + "/certs/server.key"    $SERVER_ADDRESS = "0.0.0.0"  $SERVER_PORT = 7767  $AUTH_KEY = ""  $DEBUG = false  $LOG = WEBrick::Log.new(LOG_FILE)    $SSL_ENABLE = false  $SSL_CERT = ''  $SSL_PKEY = ''    $THREADS = {}    class HwDaemonApiHandler < XMLRPC::WEBrickServlet          def version       DAEMON_VERSION    end        def exec(command, args = '')      output = `#{command} #{args} 2>&1`      exit_code = $?      $LOG.debug("Exec command: #{command} #{args}; code: #{exit_code}; output:n#{output}")      { 'exit_code' => exit_code >> 8, 'output' => output }    end        def job(command, args = '')      job_id = generate_id            t = Thread.new do        result = self.exec(command, args)        $THREADS[job_id]['result'] = result      end                $THREADS[job_id] = { 'thread' => t }            { 'job_id' => job_id }    end        def job_status(job_id)      found = $THREADS.has_key?(job_id)      result = ''            if found        alive = $THREADS[job_id]['thread'].alive?        result = $THREADS[job_id]['result'] unless alive      end            { 'found' => found, 'alive' => alive, 'result' => result }    end        def write_file(filename, content)      File.open(filename, 'w') { |file| file.write(content) }      $LOG.debug("Writing file: #{filename}")    end        def service(request, response)      WEBrick::HTTPAuth.basic_auth(request, response, '') do |user, password|        user == 'admin' &amp
;& password == $AUTH_KEY      end             super    end        def handle(method, *params)      $LOG.debug("Execute method: #{method}")          super    end        private        def generate_id      symbols = [('0'..'9'),('a'..'f')].map{ |i| i.to_a }.flatten      (1..32).map{ symbols[rand(symbols.length)] }.join    end      end    class HwDaemonUtil        def initialize      check_environment            if (0 == ARGV.size)        do_help      end        load_config      $LOG.level = WEBrick::Log::DEBUG if $DEBUG        if $SSL_ENABLE        require 'webrick/https'        $SSL_CERT = OpenSSL::X509::Certificate.new(File.open(SSL_CERT_FILE).read) if File.readable?(SSL_CERT_FILE)        $SSL_PKEY = OpenSSL::PKey::RSA.new(File.open(SSL_PKEY_FILE).read) if File.readable?(SSL_PKEY_FILE)      end            command = ARGV[0]        case command        when 'start'          do_start        when 'stop'          do_stop        when 'restart'          do_restart        when 'status'          do_status        else          do_help      end    end        def check_environment      if RUBY_VERSION !~ /1.8..+/        puts "Ruby #{RUBY_VERSION} is not supported."        exit(1)      end            if !File.exists?('/proc/vz/version')        puts "Daemon should be run on the server with OpenVZ."        exit(1)      end    end        def do_start      puts "Starting the daemon..."            servlet = HwDaemonApiHandler.new      servlet.add_handler("hwDaemon", servlet)         servlet.set_default_handler do |name, *args|        raise XMLRPC::FaultException.new(-99, "Method #{name} missing or wrong number of parameters!")      end            server = WEBrick::HTTPServer.new(        :Port => $SERVER_PORT,        :BindAddress => $SERVER_ADDRESS,        :Logger => $LOG,        :SSLEnable => $SSL_ENABLE,        :SSLVerifyClient => ($SSL_ENABLE ? OpenSSL::SSL::VERIFY_NONE : nil),        :SSLCertificate => $SSL_CERT,        :SSLPrivateKey => $SSL_PKEY,        :SSLCertName => [ [ "CN", WEBrick::Utils::getservername ] ]      )            server.mount('/xmlrpc', servlet)            ['INT', 'TERM'].each { |signal| trap(signal) { server.shutdown } }        WEBrick::Daemon.start do        write_pid_file        server.start        delete_pid_file      end    end        def do_stop      if (File.exists?(PID_FILE))        pid = File.read(PID_FILE)        $LOG.debug("Killing process with PID #{pid.to_i}")        Process.kill('TERM', pid.to_i)      end            puts "Daemon was stopped."    end        def do_restart      do_stop      do_start    end        def do_status      if (File.exists?(PID_FILE))        puts "Daemon is running."      else        puts "Daemon is stopped."        exit(1)      end    end        def do_help      puts "Usage: ruby hw-daemon.rb (start|stop|restart|status|help)"      exit(1)    end        def load_config          file = File.new(CONFIG_FILE, 'r')            while (line = file.gets)        key, value = line.split('=', 2).each { |v| v.strip! }                case key          when 'address'            $SERVER_ADDRESS = value          when 'port'            $SERVER_PORT = value          when 'key'            $AUTH_KEY = value          when 'ssl'            $SSL_ENABLE = true if value == 'on'          when 'debug'            $DEBUG = true if value == 'on'                  end      end            file.close    end        def write_pid_file      open(PID_FILE, "w") { |file| file.write(Process.pid) }     end        def delete_pid_file      if File.exists?(PID_FILE)        File.unlink PID_FILE      end    end      end    HwDaemonUtil.new  

via:http://www.facebooksx.com/centosopenvzopenvzwebpanel.html
挺好的实用教程,怕博主放弃,置于此。

CentOS安装OpenVZ并配置OpenVZ Web Panel – 主机百科