【鼎革‧革鼎】︰ Raspbian Stretch 《六之 G.1 》

登廬山望石門‧宋鮑照

訪世失隱淪,從山異靈士。
明發振雲冠,升嶠遠棲趾。
高岑隔半天,長崖斷千里。
氛霧承星辰,潭壑洞江汜。
嶄絕類虎牙,巑岏象熊耳。
埋冰或百年,韜樹必千祀。
雞鳴清澗中,猿嘯白雲裏。
瑤波逐穴開,霞石觸峰起。
迴互非一形,參差悉相似。
傾聽鳳管賓,緬望釣龍子。
松桂盈膝前,如何穢城市。

振羽 %e7%be%bd 騰空之時,音聲分明。發芽 %e8%8a%bd 伏藏之際,難得頃聽。

─── 《樹莓派聲音︰頃聽者

 

□ ︰ 為什麼樹莓派自帶之類比一直以來不好?

○ ︰ 因為使用 PWM 之故!

□ ︰ 早有許多 I2S 數位卡,怎麼不改之耶?

○ ︰ 樂求其省又便宜,利於學習和攜帶也。

□ ︰ 不過當今之聲卡既已貴且重矣!!豈至??

○ ︰ 此乃應用在人,藏富於天下者之思。

+ ︰ 胡復何有疑焉◎

 

北斗雖遷仍然指春!古今遺音依舊能解?

念大化川流不息之旨有乎??!!

Bluetooth audio

In Jessie, we used PulseAudio to provide support for audio over Bluetooth, but integrating this with the ALSA architecture used for other audio sources was clumsy. For Stretch, we are using the bluez-alsa package to make Bluetooth audio work with ALSA itself. PulseAudio is therefore no longer installed by default, and the volume plugin on the taskbar will no longer start and stop PulseAudio. From a user point of view, everything should still work exactly as before – the only change is that if you still wish to use PulseAudio for some other reason, you will need to install it yourself.

※ 註

Bluetooth Audio ALSA Backend

This project is a rebirth of a direct integration between Bluez and ALSA. Since Bluez >= 5, the build-in integration has been removed in favor of 3rd party audio applications. From now on, Bluez acts as a middleware between an audio application, which implements Bluetooth audio profile, and a Bluetooth audio device.

The current status quo is, that in order to stream audio from/to a Bluetooth device, one has to install PulseAudio, or use Bluez < 5. However, Bluez version 4 is considered to be deprecated, so the only reasonable way to achieve this goal is to install PulseAudio.

With this application (later named as BlueALSA), one can achieve the same goal as with PulseAudio, but with less dependencies and more bare-metal-like. BlueALSA registers all known Bluetooth audio profiles in Bluez, so in theory every Bluetooth device (with audio capabilities) can be connected. In order to access the audio stream, one has to connect to the ALSA PCM device called bluealsa. The device is based on the ALSA software PCM plugin.

 

想古今世代交替之轉無耶!!??

Better handling of other usernames

The default user account in Raspbian has always been called ‘pi’, and a lot of the desktop applications assume that this is the current user. This has been changed for Stretch, so now applications like Raspberry Pi Configuration no longer assume this to be the case. This means, for example, that the option to automatically log in as the ‘pi’ user will now automatically log in with the name of the current user instead.

One other change is how sudo is handled. By default, the ‘pi’ user is set up with passwordless sudo access. We are no longer assuming this to be the case, so now desktop applications which require sudo access will prompt for the password rather than simply failing to work if a user without passwordless sudo uses them.

 

 

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 G 》

祇聽 Mrphs 講完… W!o+ 『拙』於用『巧』 ……,過了沒多久之後 ,便迷上了『先人科技』,愛說什麼︰

古今『 為 用 』為用;乾坤『 借 法 』借法。

痛痛快快的將找得的『前代軟體』給『玩』得個『透』『通』!!因此 W!o+ 認為『借法』,『法生』、『生法』,生生不息!!!

※作者註︰據聞『借法』一詞出自

太乙天尊‧《太一拔罪斬妖護身咒

操天道、化兩儀,生陰陽、轉乾坤,應赦令。

天地無極,乾坤借法;法由心生,生生不息。
太乙天尊,急急如律令!

乾坤無極,風雷受命;龍戰于野,十方俱滅。
太乙天尊,急急如律令!

伏化天王,降定天一;天地玄黄,陰陽妙法。
太乙天尊,急急如律令!

天羅維網,地閻摩羅;慧劍出鞘,斬妖誅精;一切災難化為塵 。
太乙天尊,急急如律令!

── 《W!o+ 的《小伶鼬工坊演義》︰【新春】 復古派 《六》 RetroPie 借法

 

欲言今日 Raspbian Stretch 之 Audio ,先想到了『視、聽』的 kodi ,眼下直須

sudo apt-get install kodi

可也!

pi@raspberrypi:~ $ apt-cache show kodi
Package: kodi
Version: 2:17.5-1~stretch
Architecture: all
Source: kodi
Depends: kodi-bin (>= 2:17.5-1~stretch), kodi-bin (<< 2:17.5-1~stretch.1~), curl, libcurl3, mesa-utils, x11-utils, fonts-liberation | ttf-liberation, fonts-dejavu-core | ttf-dejavu-core, python-bluez | python-lightblue, python-imaging, python-simplejson, libass5 | libass4, libgif5 | libgif7, libssh-4 | libssh2-1, libnfs8 | libnfs4 | libnfs1, libbluray1, libshairplay0, libvorbisfile3, libaacs0, libcec4, libgnutls30 | libgnutls-deb0-28 | libgnutls28 | libgnutls26, libxslt1.1, libyajl2
Recommends: libvdpau1, libva-intel-vaapi-driver, libva1
Suggests: kodi-pvr-mythtv, kodi-pvr-vuplus, kodi-pvr-vdr-vnsi, kodi-pvr-njoy, kodi-pvr-nextpvr, kodi-pvr-mediaportal-tvserver, kodi-pvr-tvheadend-hts, kodi-pvr-dvbviewer, kodi-pvr-argustv, kodi-pvr-iptvsimple, kodi-audioencoder-vorbis, kodi-audioencoder-flac, kodi-audioencoder-lame
Homepage: http://kodi.tv
Breaks: xbmc (<< 2:14.0~git20141019), xbmc-data, xbmc-standalone
Provides: kodi-data, kodi-skin-estuary, kodi-standalone, xbmc, xbmc-data, xbmc-standalone
Replaces: xbmc (<< 2:14.0~git20141019), xbmc-data, xbmc-standalone
Installed-Size: 37663
Maintainer: Diogo Santos <diogomsantos@hotmail.com>
Priority: optional
Section: video
Filename: pool/main/k/kodi/kodi_17.5-1~stretch_all.deb

 

打算如何擷圖

 

 

 

展示乎?忽爾又憶起乾坤借法

莫非,老矣朽矣!要不怎就突然思接孟子

萬章上

萬章曰:「堯以天下與舜,有諸?」

孟子曰:「否。天子不能以天下與人。」

「然則舜有天下也,孰與之?」

曰:「天與之。」

「天與之者,諄諄然命之乎?」

曰:「否。天不言,以行與事示之而已矣。」

曰:「以行與事示之者如之何?」

曰:「天子能薦人於天,不能使天與之天下;諸侯能薦人於天子,不能使天子與之諸侯;大夫能薦人於諸侯,不能使諸侯與之大夫。昔者堯薦舜於天而天受之,暴之於民而民受之,故曰:天不言,以行與事示之而已矣。」

曰:「敢問薦之於天而天受之,暴之於民而民受之,如何?」

曰:「使之主祭而百神享之,是天受之;使之主事而事治,百姓安之,是民受之也。天與之,人與之,故曰:天子不能以天下與人。舜相堯二十有八載,非人之所能為也,天也。堯崩,三年之喪畢,舜避堯之子於南河之南。天下諸侯朝覲者,不之堯之子而之舜;訟獄者,不之堯之子而之舜;謳歌者,不謳歌堯之子而謳歌舜,故曰天也。夫然後之中國,踐天子位焉。而居堯之宮,逼堯之子,是篡也,非天與也。《太誓》曰:『天視自我民視,天聽自我民聽』,此之謂也。」

 

耶?反倒納罕言語文字意義之變遷,是反映自然還是社會改變哩!

 

 

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 F.5 》

既然談了 VNC 伺服器,焉能不提及 Karl J. Runge 先生之出類拔萃的

x11vnc: a VNC server for real X displays

x11vnc allows one to view remotely and interact with real X displays (i.e. a display corresponding to a physical monitor, keyboard, and mouse) with any VNC viewer. In this way it plays the role for Unix/X11 that WinVNC plays for Windows.

It has built-in SSL/TLS encryption and 2048 bit RSA authentication, including VeNCrypt support; UNIX account and password login support; server-side scaling; single port HTTPS/HTTP+VNC; Zeroconf service advertising; and TightVNC and UltraVNC file-transfer. It has also been extended to work with non-X devices: natively on Mac OS X Aqua/Quartz, webcams and TV tuner capture devices, and embedded Linux systems such as Qtopia Core. Full IPv6 support is provided. More features are described here.

It also provides an encrypted Terminal Services mode (-create, -svc, or -xdmsvc options) based on Unix usernames and Unix passwords where the user does not need to memorize his VNC display/port number. Normally a virtual X session (Xvfb) is created for each user, but it also works with X sessions on physical hardware. See the tsvnc terminal services mode of the SSVNC viewer for one way to take advantage of this mode.

I wrote x11vnc back in 2002 because x0rfbserver was basically impossible to build on Solaris and had poor performance. The primary x0rfbserver build problems centered around esoteric C++ toolkits. x11vnc is written in plain C and needs only standard libraries and so should work on nearly all Unixes, even very old ones. I also created enhancements to improve the interactive response, added many features, and etc.

This page including the FAQ contains much information [*]; solutions to many problems; and interesting applications, but nevertheless please feel free to contact me if you have problems or questions (and if I save you time or expense by giving you some of my time, please consider a PayPal Donation.) Do check the FAQ and this page first; I realize the pages are massive, but you can often use your browser’s find-in-page search action using a keyword to find the answer to your problem or question.

SSVNC:  An x11vnc side-project provides an Enhanced TightVNC Viewer package (SSVNC) for Unix, Windows, and Mac OS X with automatic SSL and/or SSH tunnelling support, SSL Certificate creation, Saved connection profiles, Zeroconf, VeNCrypt, and built-in Proxy support. Added features for the TightVNC Unix viewer: NewFBSize, ZRLE encoding, Viewer-side Scaling, cursor alphablending, low color modes, and enhanced popup menu; UltraVNC extensions support for: File Transfer, Text Chat, Single Window, Server Input, and 1/n Scaling extensions, and UltraVNC DSM encryption. The SSVNC bundle could be placed on, say, a USB memory stick for SSL/SSH VNC viewing from nearly any networked computer.

 

程式也!舉例來說,在樹莓派上如何作逆向 VNC 連接的呢?

Starting Listening VNC Viewer and establishing a reverse connection

You can establish a reverse connection to a Listening VNC Viewer, allowing the Viewer user to bypass the authentication scheme and control the Server User’s computer. When a connection is made in this way, VNC Viewer does not connect to VNC Server, but instead waits for VNC Server to connect to it.

This feature is useful if your computer is protected by a firewall that cannot be configured to allow – or by a router that cannot be configured to forward – network communications, thus preventing incoming connections. In a reverse connection, network communications from the Server user’s computer are outgoing.

Note: Reverse connections are not secure and should only be used in a locked-down environment.

Configuring Listening VNC Viewer

Starting Listening VNC Viewer

  •   Under Windows or Mac OS X, search for or navigate to the Listening VNC Viewer program.
  •   Under UNIX, you must start Listening VNC Viewer at the command line. If VNC Viewer is installed on your system, run:

vncviewer –listen [<port>]

If you use the standalone version of VNC Viewer, run:

./<download-file> -listen [<port>]

 

【觀看客戶端】

vncviewer -listen 5500

 

【伺服器端】

x11vnc -connect 觀看客戶端 IP :5500

 

就得了!?還可藉此工具了解 VNC 規範連線效能以及選項運用?!將能自製酪梨 client 乎!!??

PyGuacamole

A Python client library for communication with Guacamole server (guacd)

Installation

Using pip

pip install pyguacamole</pre> <span style="color: #808080;">From source</span> <pre class="lang:default decode:true "> python setup.py install

Usage

GuacamoleClient handles communication with a running guacd server via Guacamole Protocol.

GuacamoleClient must be used by a broker server which handles communication with a Javscript application running in the browser. GuacamoleClient implements the methods that enables communication with guacd server (send & receive).

First step should be establishing handshake with guacd server, then Broker server should handle instruction sending and receiving:

  • send: send instruction to guacd server
  • receive: receive instruction from guacd server

……

 

唯因目前其喜派生二 Python ︰

pi@raspberrypi:~ sudo pip install pyguacamole Collecting pyguacamole   Downloading pyguacamole-0.6.tar.gz Collecting future>=0.15.2 (from pyguacamole)   Downloading future-0.16.0.tar.gz (824kB)     100% |████████████████████████████████| 829kB 298kB/s  Requirement already satisfied: six>=1.10.0 in /usr/lib/python2.7/dist-packages (from pyguacamole) Building wheels for collected packages: pyguacamole, future   Running setup.py bdist_wheel for pyguacamole ... done   Stored in directory: /root/.cache/pip/wheels/f9/6d/74/876c143097972169cef3fa99508be9b37f3564400f46baa236   Running setup.py bdist_wheel for future ... done   Stored in directory: /root/.cache/pip/wheels/c2/50/7c/0d83b4baac4f63ff7a765bd16390d2ab43c93587fac9d6017a Successfully built pyguacamole future Installing collected packages: future, pyguacamole Successfully installed future-0.16.0 pyguacamole-0.6  pi@raspberrypi:~ python
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from guacamole.client import GuacamoleClient
>>> client = GuacamoleClient('127.0.0.1', 4822)
>>> client.handshake(protocol='rdp', hostname='localhost', port=3389)
>>> instruction = client.receive()
>>> instruction
'4.size,1.0,4.1024,3.768;'
>>> instruction = '5.mouse,3.400,3.500;'
>>> client.send(instruction)
>>> 

 

故待挺進派生三的呦??!!

pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from guacamole.client import GuacamoleClient
>>> client = GuacamoleClient('127.0.0.1', 4822)
>>> client.handshake(protocol='vnc', hostname='localhost', port=5900)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/guacamole/client.py", line 158, in handshake
    self.send_instruction(Instruction('select', protocol))
  File "/usr/local/lib/python3.5/dist-packages/guacamole/client.py", line 136, in send_instruction
    return self.send(instruction.encode())
  File "/usr/local/lib/python3.5/dist-packages/guacamole/client.py", line 122, in send
    self.client.sendall(data)
TypeError: a bytes-like object is required, not 'str'
>>>

 

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 F.4 》

將要如何設定酪梨 guacamole 呢?這裡作者不過假借

[TUTORIAL] Jetty and Guacamole

VNC (Virtual Network Computing)

文本,略作補充耳。

【官方佈署文件】

The web application portion of Guacamole is packaged as a fully self-contained .war file. If you downloaded Guacamole from the main project web site, this file will be called guacamole.war. Deploying this involves copying the file into the directory your servlet container uses for .war files. In the case of Tomcat, this will be CATALINA_HOME/webapps/. The location of CATALINA_HOME will vary by how Tomcat was installed, but is commonly /var/lib/tomcat, /var/lib/tomcat7, or similar:

# cp guacamole.war /var/lib/tomcat/webapps
#

 

取得對應之 .war 封裝檔

wget https://sourceforge.net/projects/guacamole/files/current/binary/guacamole-0.9.13-incubating.war

 

將之拷貝至 jetty9 之 webapps 目錄。

sudo cp guacamole-0.9.13-incubating.war /usr/share/jetty9/webapps/

※ 參考

pi@raspberrypi:~ cd /usr/share/jetty9/webapps pi@raspberrypi:/usr/share/jetty9/webapps ls
guacamole.war  root
pi@raspberrypi:/usr/share/jetty9/webapps </pre>   <pre class="lang:default decode:true">pi@raspberrypi:/usr/share/jetty9/webapps cd /var/cache/jetty9/data/jetty-0.0.0.0-8080-guacamole.war-_guacamole-any-5680714153949901226.dir/webapp
pi@raspberrypi:/var/cache/jetty9/data/jetty-0.0.0.0-8080-guacamole.war-_guacamole-any-5680714153949901226.dir/webapp ls app                  guacamole.css      images       META-INF fonts                guacamole.js       index.html   relocateParameters.js generated            guacamole.min.css  layouts      translations guacamole-common-js  guacamole.min.js   license.txt  WEB-INF pi@raspberrypi:/var/cache/jetty9/data/jetty-0.0.0.0-8080-guacamole.war-_guacamole-any-5680714153949901226.dir/webapp

 

【官方組構文件】

After installing Guacamole, you need to configure users and connections before Guacamole will work. This chapter covers general configuration of Guacamole and the use of its default authentication method.

Guacamole’s default authentication method reads all users and connections from a single file called user-mapping.xml. This authentication method is intended to be:

  1. Sufficient for small deployments of Guacamole.
  2. A relatively-easy means of verifying that Guacamole has been properly set up.

Other, more complex authentication methods which use backend databases, LDAP, etc. are discussed in a separate, dedicated chapters.

Regardless of the authentication method you use, Guacamole’s configuration always consists of two main pieces: a directory referred to as GUACAMOLE_HOME, which is the primary search location for configuration files, and guacamole.properties, the main configuration file used by Guacamole and its extensions.

 

樹莓派 realvnc 伺服器簡易設定檔︰

建立 /usr/share/jetty9/.guacamole 目錄

pi@raspberrypi:~ cd /usr/share/jetty9/.guacamole/ pi@raspberrypi:/usr/share/jetty9/.guacamole ls
guacamole.properties  user-mapping.xml

 

創建 guacamole.properties 文字檔

pi@raspberrypi:/usr/share/jetty9/.guacamole more guacamole.properties  # Hostname and port of guacamole proxy guacd-hostname: localhost guacd-port:     4822  # Location to read extra .jar's from lib-directory:  /usr/share/jetty9/.guacamole  # Authentication provider class auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvid er  # Properties used by BasicFileAuthenticationProvider  # Properties used by BasicFileAuthenticationProvider basic-user-mapping: /usr/share/jetty9/.guacamole/user-mapping.xml pi@raspberrypi:/usr/share/jetty9/.guacamole

 

創建 user-mapping.xml 文字檔

pi@raspberrypi:/usr/share/jetty9/.guacamole more user-mapping.xml  <user-mapping>      <authorize username="pi" password="raspberry">         <connection name="VNC-Connection">              <protocol>vnc</protocol>              <param name="hostname">localhost</param>              <param name="port">5900</param>              <param name="password">raspberry</param>        </connection>     </authorize>  </user-mapping>  pi@raspberrypi:/usr/share/jetty9/.guacamole 

 

啟用 VNC 伺服器

 

打開 VNC 伺服器對話窗,選擇使用 VNC password ,此處作者並未顧慮安全將之任意設定為 raspberry 。

 

實測者應會發現 guacd 服務在重新開機後起不來也?

pi@raspberrypi:~ service guacd status ● guacd.service - LSB: Guacamole proxy daemon    Loaded: loaded (/etc/init.d/guacd; generated; vendor preset: enabled)    Active: inactive (dead)      Docs: man:systemd-sysv-generator(8) pi@raspberrypi:~

 

雖說可以 rc.local 拗救!

pi@raspberrypi:~ more /etc/rc.local  #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing.  # Print the IP address _IP=(hostname -I) || true
if [ "_IP" ]; then   printf "My IP address is %s\n" "_IP"
fi

sudo service guacd restart

exit 0
pi@raspberrypi:~ </pre>    <span style="color: #666699;">何不就嘗試利用 systemd-sysv 相容產生器呢?!</span>  <span style="color: #ff9900;">sudo systemctl enable guacd</span> <pre class="lang:default decode:true ">pi@raspberrypi:~ cd /run/systemd/generator.late/
pi@raspberrypi:/run/systemd/generator.late ls dphys-swapfile.service  guacd.service   multi-user.target.wants graphical.target.wants  jetty9.service  raspi-config.service pi@raspberrypi:/run/systemd/generator.late 
pi@raspberrypi:/run/systemd/generator.late more guacd.service  # Automatically generated by systemd-sysv-generator  [Unit] Documentation=man:systemd-sysv-generator(8) SourcePath=/etc/init.d/guacd Description=LSB: Guacamole proxy daemon Before=multi-user.target Before=multi-user.target Before=multi-user.target Before=graphical.target After=network-online.target Wants=network-online.target  [Service] Type=forking Restart=no TimeoutSec=5min IgnoreSIGPIPE=no KillMode=process GuessMainPID=no RemainAfterExit=yes SuccessExitStatus=5 6 ExecStart=/etc/init.d/guacd start ExecStop=/etc/init.d/guacd stop pi@raspberrypi:/run/systemd/generator.late 

 

畢竟 rc-local.service 也是這麼來的!?

pi@raspberrypi:~ cd /run/systemd/generator/multi-user.target.wants/ pi@raspberrypi:/run/systemd/generator/multi-user.target.wants ls
rc-local.service
pi@raspberrypi:/run/systemd/generator/multi-user.target.wants pi@raspberrypi:/run/systemd/generator/multi-user.target.wants more rc-local.service 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
pi@raspberrypi:/run/systemd/generator/multi-user.target.wants </pre>    <span style="color: #666699;">無怪乎正常耶☆</span> <pre class="lang:default decode:true">pi@raspberrypi:~ systemctl status guacd
● guacd.service - LSB: Guacamole proxy daemon
   Loaded: loaded (/etc/init.d/guacd; generated; vendor preset: enabled)
   Active: active (running) since Wed 2017-11-08 20:04:57 CST; 1 day 20h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 420 ExecStart=/etc/init.d/guacd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/guacd.service
           ├─ 454 /usr/local/sbin/guacd -p /var/run/guacd.pid
           └─2793 /usr/local/sbin/guacd -p /var/run/guacd.pid

Warning: Journal has been rotated since unit was started. Log output is incomple
pi@raspberrypi:~ $

 

 

至於怎樣玩轉酪梨,還請讀者自讀

【官方使用文件】

Guacamole provides access to much of the functionality of a desktop from within your web browser. Although most people use remote desktop tools only when absolutely necessary, we believe that Guacamole must be aimed at becoming a primary means of accessing desktops, and the interface is thus intended to be as seamless and unobtrusive as possible.

 

哩◎

 

 

 

 

 

 

 

【鼎革‧革鼎】︰ Raspbian Stretch 《六之 F.3下 》

過去想要知道 □ □ linux 的啟動過程,如能深入了解

init

init(為英語:initialization的簡寫)是 Unix類Unix 系統中用來產生其它所有行程的程式。它以守護行程的方式存在,其行程號為1。Linux系統在開機時載入Linux內核後,便由Linux內核載入init程式,由init程式完成餘下的開機過程,比如載入執行級別,載入服務 ,啟動Shell/圖形化介面等等。

Unix 系列中(如 System IIISystem V)init的作用,和研究中的 UnixBSD 衍生版本相比,發生了一些變化。大多數Linux發行版是和 System V 相相容的,但是一些發行版如Slackware 採用的是BSD風格,其它的如 Gentoo 是自己客製的。後來Ubuntu[1][2] 和其他一些發行版採用 Upstart[3] 來代替[4] 傳統的 init 處理程式。至2015年,大部分Linux發行版都已採用新的systemd替代System VUpstart,但systemd向下相容System V

BSD風格

BSD init 執行存放於’/etc/rc’的初始化 shell 指令碼,然後啟動基於文字模式的終端(getty)或者基於圖形介面的終端(窗口系統,如 X)。 這裡沒有執行模式的問題,因為檔案 ‘rc’ 決定了 init 如何執行。

優點: 簡單且易於手動編輯。

缺點: 如果第三方軟體需要在啟動過程執行它自身的初始化指令碼,它必須修改已經存在的啟動指令碼,一旦這種過程中有一個小錯誤 ,都將導致系統無法正常啟動。

值得注意的是,現代的 BSD 衍生系統一直支援使用 ‘rc.local’ 檔案的方式,它將在正常啟動過程接近最後的時間以子指令碼的方式來執行。這樣做減少了整個系統無法啟動的風險。然後,第三方軟體包可以將它們獨立的 start/stop 指令碼安裝到一個原生的 ‘rc.d’ 目錄中(通常這是由 ports collection/pkgsrc 完成的)。 FreeBSDNetBSD 現在預設使用 rc.d ,該目錄中所有的用戶啟動指令碼,都被分成更小的子指令碼,和 SysV 類似。rcorder 通常根據在 rc.d目錄中指令碼之間的依賴關係來決定指令碼的執行順序。

SysV風格

System V init 檢查 ‘/etc/inittab’ 檔案中是否含有 ‘initdefault’ 項。 這告訴 init 系統是否有一個預設執行模式。如果沒有預設的執行模式 ,那麼用戶將進入系統控制台,手動決定進入何種執行模式。

優點:靈活性強

缺陷:比較複雜

 

程式大概思過半矣!今天還得明白

systemd

systemdLinux電腦作業系統之下的一套中央化系統及設定管理程式init軟體),包括有守護行程程式庫跟應用軟體,由Lennart Poettering帶頭開發。其開發目標是提供更優秀的框架以表示系統服務間的依賴關係,並依此實現系統初始化時服務的並列啟動,同時達到降低Shell系統開銷的效果,最終代替現在常用的System VBSD風格init程式。

目前絕大多數的Linux發行版都已採用systemd代替原來的System V

systemd在LGPL 2.1及其後續版本許可證下開源發布[1][2]

起源

systemd這一名字源於Unix中的一個慣例:在Unix中常以「d」作為系統守護行程英語:daemon,亦稱後台行程)的字尾標識。除此以外,systemd亦是借代英文術語D體系,而這一術語即是用於描述一個人具有快速地適應環境並解決困難的能力[3]

設計

 

systemd組件

 

專門由systemd所使用的統一層次結構控制組

System V風格init相比,systemd採用了以下新技術:

  • 將service(服務)、target(執行模式,類似於執行等級)、mount、timer、snapshot、path、socket、 swap等稱為Unit。比如,一個auditd服務(就是auditd.service)就是一個Unit,一個multi-user.target執 行模式也是一個Unit。
  • 採用Socket啟用式與D-Bus啟用式服務,以提高相互依賴的各服務的並列執行效能;
  • cgroups代替行程ID來追蹤行程,以此即使是兩次fork之後生成的守護行程也不會脫離systemd的控制。
  • 用target代替System V的執行級別(Runlevel),比如,SystemD的graphical.target相當於System V的init 5,multi-user.target相當於System V的init 3。
  • 內建新的journald 日誌管理系統。
  • 引入localectltimedatectl等新命令,系統配置更方便。

從設計構思上說,由於systemd使用了cgroup與fanotify等元件以實現其特性,所以只適用於Linux[4]。有鑑於此,考慮到kFreeBSD分支的軟體源無法納入systemd,為與其他分支保持一致,Debian開發者盡力避免納入systemd[5]。但Lennart Poettering本人對此並不在意,並稱「Debian GNU/kFreeBSD不過是玩具系統」[6]。但Debain 8.0 Jessie開始以systemd取代sysvinit。[7]

 

架構。熟悉 Debian 發行版之想法︰

How to LSBize an Init Script

A status page for dependency based boot sequencing is available.

This is a short documentation about how to make an Init Script LSB (Linux Standard Base)-compliant based on the Chapter 20 of the LSB 3.1.

LSB-compliant init scripts need to:

and should also follow Debian Policy, chapter 9.4 Console messages from init.d scripts)

Full information on the actions (and return codes) that LSB scripts have to honor are available at LSB 3.1, Chapter 20.2. Init Script Actions. Maintainers should review that section and review / adjust their init.d scripts accordingly.

……

systemd – system and service manager

………

SYSTEMD-SYSV-GENERATOR(8) systemd-sysv-generator SYSTEMD-SYSV-GENERATOR(8)

NAME

systemd-sysv-generator – Unit generator for SysV init scripts

SYNOPSIS

/lib/systemd/system-generators/systemd-sysv-generator

DESCRIPTION

systemd-sysv-generator is a generator that creates wrapper .service units for SysV init[1] scripts in /etc/init.d/* at boot and when configuration of the system manager is reloaded. This will allow systemd(1) to support them similarly to native units.

 LSB headers[2] in SysV init scripts are interpreted, and the ordering specified in the header is turned into dependencies between the generated unit and other units. The LSB facilities “remote_fs", "network”, “named", "portmap”, “

*** QuickLaTeX cannot compile formula:
time" are supported and will be turned into dependencies on specific native systemd targets. See <b>systemd.special</b>(5) for more details.</span></div>
<div class="Pp"><span style="color: #808080;"> </span></div>
<div class="Pp"><span style="color: #808080;">SysV runlevels have corresponding systemd targets (runlevel <i>X</i>.target). The wrapper unit that is generated will be wanted by those targets which correspond to runlevels for which the script is enabled.</span></div>
<div class="Pp"></div>
<div class="Pp"><span style="color: #808080;"> </span><span style="color: #808080;"><b>systemd</b> does not support SysV scripts as part of early boot, so all wrapper units are ordered after basic.target.</span></div>
<div class="Pp"><span style="color: #808080;"> </span></div>
<div class="Pp"><span style="color: #808080;">systemd-sysv-generator implements <a style="color: #808080;" href="https://manpages.debian.org/stretch/systemd/systemd.generator.7.en.html">systemd.generator(7)</a>.</span></div>
</div>
 

<span style="color: #666699;">方便悠遊 Raspbian Stretch 的天空呦!!</span>

<span style="color: #666699;">假使缺乏經驗與學習︰</span>
<h1><span style="color: #ff9900;"><a style="color: #ff9900;" href="http://linux.vbird.org/linux_basic/0560daemons.php">第十七章、認識系統服務 (daemons)</a></span></h1>
<div class="abstract">

<span style="color: #808080;">在 Unix-Like 的系統中,你會常常聽到 daemon 這個字眼!那麼什麼是傳說中的 daemon 呢?這些 daemon 放在什麼地方?他的功能是什麼?該如何啟動這些 daemon ?又如何有效的將這些 daemon 管理妥當?此外,要如何視察這些 daemon 開了多少個 ports ?又這些 ports 要如何關閉?還有還有,曉得你系統的這些 port 各代表的是什麼服務嗎? 這些都是最基礎需要注意的呢!尤其是在架設網站之前,這裡的觀念就顯的更重要了。</span>

<span style="color: #808080;">從 CentOS 7.x 這一版之後,傳統的 init 已經被捨棄,取而代之的是 systemd 這個傢伙~這傢伙跟之前的 init 有什麼差異? 優缺點為何?如何管理不同種類的服務類型?以及如何取代原本的『執行等級』等等,很重要的改變喔!</span>

</div>
<div class="links">
<ul>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#daemon">17.1 什麼是 daemon 與服務 (service)</a></span>
<ul>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#daemon_type_init">17.1.1 早期 Systemp V 的 init 管理行為中 daemon 的主要分類</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#daemon_type_systemd">17.1.2 systemd 使用的 unit 分類</a></span></li>
</ul>
</li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemctl_cmd">17.2 透過 systemctl 管理服務</a></span>
<ul>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemctl_start">17.2.1 透過 systemctl 管理單一服務 (service unit) 的啟動/開機啟動與觀察狀態</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemctl_list">17.2.2 透過 systemctl 觀察系統上所有的服務</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemctl_target">17.2.3 透過 systemctl 管理不同的操作環境 (target unit)</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemctl_deps">17.2.4 透過 systemctl 分析各服務之間的相依性</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemctl_files">17.2.5 與 systemd 的 daemon 運作過程相關的目錄簡介</a>: <a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#etc_services">/etc/services</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemctl_network">17.2.6 關閉網路服務</a></span></li>
</ul>
</li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemd_cfg">17.3 systemctl 針對 service 類型的設定檔</a></span>
<ul>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemd_cfg_dir">17.3.1 systemctl 設定檔相關目錄簡介</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemd_cfg_options">17.3.2 systemctl 設定檔的設定項目簡介</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemd_cfg_vsftpd">17.3.3 兩個 vsftpd 運作的實例</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemd_cfg_repeat">17.3.4 多重的重複設定方式:以 getty 為例</a></span></li>
 	<li><span style="color: #808080;"><a style="color: #808080;" href="http://linux.vbird.org/linux_basic/0560daemons.php#systemd_cfg_custom">17.3.5 自己的服務自己作</a></span></li>
</ul>
</li>
</ul>
</div>
<span style="color: #808080;">……</span>
<h1 class="title"><span style="color: #ff9900;"><a style="color: #ff9900;" href="https://www.turnkeylinux.org/blog/debugging-systemd-sysv-init-compat">systemd sysv init compatibility mode: how it works and troubleshooting when it breaks</a></span></h1>
<span class="submitted" style="color: #808080;"><a style="color: #808080;" href="https://www.turnkeylinux.org/users/liraz">Liraz Siri</a> - Sat, 2015/11/28 - 11:06 - <a class="comment-count" style="color: #808080;" title="4 comments" href="https://www.turnkeylinux.org/blog/debugging-systemd-sysv-init-compat#comments">4 comments</a> | Latest by <span class="username">Guest</span> </span>
<div class="content">
<div class="field field-name-body field-type-text-with-summary field-label-hidden">
<div class="field-items">
<div class="field-item even">

<span style="color: #808080;">systemd sysv init compatibility mode is magical. That is in the sense that it tries to handle compatibility with sysv init scripts while you are distracted looking somewhere else.</span>

<span style="color: #808080;">When it works it works well, but when things break it makes troubleshooting more difficult. Especially if you don't understand what's going on behind the curtain.</span>

</div>
</div>
</div>
</div>
<span style="color: #808080;">───</span>

 

<span style="color: #666699;">將怎麼賦予字詞意義和判斷結果呢??</span>
<pre class="lang:default decode:true ">pi@raspberrypi:~

*** Error message:
You can't use `macro parameter character #' in math mode.
leading text: <div class="Pp"><span style="color: #
You can't use `macro parameter character #' in math mode.
leading text: <div class="Pp"><span style="color: #
You can't use `macro parameter character #' in math mode.
leading text: <div class="Pp"><span style="color: #
You can't use `macro parameter character #' in math mode.
leading text: ...r: #808080;"> </span><span style="color: #
You can't use `macro parameter character #' in math mode.
leading text: <div class="Pp"><span style="color: #
You can't use `macro parameter character #' in math mode.
leading text: <div class="Pp"><span style="color: #
You can't use `macro parameter character #' in math mode.
leading text: ...sv-generator implements <a style="color: #

service jetty9 status
● jetty9.service – LSB: Start Jetty
Loaded: loaded (/etc/init.d/jetty9; generated; vendor preset: enabled)
Active: active (running) since Thu 2017-11-09 16:53:12 CST; 1min 11s ago
Docs: man:systemd-sysv-generator(8)
Process: 444 ExecStart=/etc/init.d/jetty9 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/jetty9.service
└─491 /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/bin/java -Xmx256m -Djava.a

11月 09 16:53:06 raspberrypi systemd[1]: Starting LSB: Start Jetty…
11月 09 16:53:12 raspberrypi jetty9[444]: Starting Jetty 9 Servlet Engine: jetty9.
11月 09 16:53:12 raspberrypi systemd[1]: Started LSB: Start Jetty.
pi@raspberrypi:~ pi@raspberrypi:~ systemctl status jetty9
● jetty9.service – LSB: Start Jetty
Loaded: loaded (/etc/init.d/jetty9; generated; vendor preset: enabled)
Active: active (running) since Thu 2017-11-09 16:53:12 CST; 1min 23s ago
Docs: man:systemd-sysv-generator(8)
Process: 444 ExecStart=/etc/init.d/jetty9 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/jetty9.service
└─491 /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/bin/java -Xmx256m -Djava.a

11月 09 16:53:06 raspberrypi systemd[1]: Starting LSB: Start Jetty…
11月 09 16:53:12 raspberrypi jetty9[444]: Starting Jetty 9 Servlet Engine: jetty9.
11月 09 16:53:12 raspberrypi systemd[1]: Started LSB: Start Jetty.
pi@raspberrypi:~ </pre>   <pre class="lang:default decode:true ">pi@raspberrypi:~ more /etc/init.d/jetty9
#!/bin/sh -e
#
# /etc/init.d/jetty9 — startup script for Jetty 9
#
# Written by Philipp Meier <meier@meisterbohne.de>
# Modified for Jetty 6 by Ludovic Claude <ludovic.claude@laposte.net>
# Modified for Jetty 8 by Jakub Adam <jakub.adam@ktknet.cz>
# Modified for Jetty 9 by Emmanuel Bourg <ebourg@apache.org>
#
### BEGIN INIT INFO
# Provides: jetty9
# Required-Start: local_fsremote_fs network # Required-Stop:local_fs remote_fsnetwork
# Should-Start: named # Should-Stop:named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Jetty
# Description: Start Jetty HTTP server and servlet container.
### END INIT INFO

# Configuration files
#
–More–(6%)

 

pi@raspberrypi:/run/systemd/generator.late ls dphys-swapfile.service  guacd.service   multi-user.target.wants graphical.target.wants  jetty9.service  raspi-config.service pi@raspberrypi:/run/systemd/generator.late 
pi@raspberrypi:/run/systemd/generator.late more jetty9.service  # Automatically generated by systemd-sysv-generator  [Unit] Documentation=man:systemd-sysv-generator(8) SourcePath=/etc/init.d/jetty9 Description=LSB: Start Jetty Before=multi-user.target Before=multi-user.target Before=multi-user.target Before=graphical.target After=remote-fs.target After=network-online.target After=nss-lookup.target Wants=network-online.target  [Service] Type=forking Restart=no TimeoutSec=5min IgnoreSIGPIPE=no KillMode=process GuessMainPID=no RemainAfterExit=yes SuccessExitStatus=5 6 ExecStart=/etc/init.d/jetty9 start ExecStop=/etc/init.d/jetty9 stop pi@raspberrypi:/run/systemd/generator.late