2018-11-15 「RASPBERRY PI インストール HDDーBOOTの場合」
Raspberry pi 3B+ からは何もしなくても、USB HDDよりブートできる。
Raspberry pi 3B は以下の手順でHDDよりブートできるようになる。
(1)メニューより端末ターミナルより
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update
(2)sudo nano /boot/config.txt
---
program_usb_boot_mode=1
---
(3)sudo reboot
(4)vcgencmd otp_dump
17:3020000a
を確認。
2018-11-15 「パッケージ、ファーム アップデート」
(1)sudo apt update
パッケージがいくつ新しくなっているかがわかる。
(2)sudo apt upgrade
(3)sudo rpi-update
(4)sudo reboot
「日本語テキスト読み上げインストール」
参考WEB
http://server-setting.info/centos/open-jtalk-install.html
(1)sudo apt-get install open-jtalk open-jtalk-mecab-naist-jdic htsengine libhtsengine-dev hts-voice-nitech-jp-atr503-m001
(2)OSDN netより
MMDAgent_Example-1.4.zip ダウンロード
(3)unzip MMDAgent_Example-1.4.zip
(4)sudo cp -R ./MMDAgent_Example-1.4/Voice/* /usr/share/hts-voice
(5)読み上げスクリプト作成
sudo nano /usr/local/sbin/talk.sh
---
#!/bin/sh
#VOICE=/usr/share/hts-voice/nitech-jp-atr503-m001/nitech_jp_atr503_m001.htsvoice
VOICE=/usr/share/hts-voice/mei/mei_normal.htsvoice
if [ "$2" = "" ]; then
SDEV=""
else
SDEV="-D plughw:$2,0"
fi
echo $1 | open_jtalk \
-m $VOICE \
-x /var/lib/mecab/dic/open-jtalk/naist-jdic \
-ow v.wav
aplay $SDEV --quiet --avail-min=88000 v.wav
rm v.wav
---
(6)sudo chmod +x /usr/local/sbin/talk.sh
(7)/etc/rc.localに追加
---
amixer cset numid=3 1 > /dev/null 2>&1
amixer cset numid=1 85% > /dev/null 2>&1
---
amixerはLine3.5mmジャック出力設定
(8)テスト
/usr/local/sbin/talk.sh おはよう
USBにスピーカを差した場合は、
/usr/local/sbin/talk.sh おはよう 1
「gitをソースからインストール」
2017-04-10-raspbian-jessie.zipで。
》mkdir setup
》cd setup
》git clone git://git.kernel.org/pub/scm/git/git.git
》sudo aptitude install autoconf automake ncurses-dev gettext libghc-zlib-dev libcurl4-openssl-dev
》sudo apt-get remove git
》cd git
》make configure
》./configure --prefix=/usr --with-curl --with-expat
》make all
》sudo make install
★gitkが動かない?
http://banikojp.blogspot.jp/2014/06/gitk.html より
> gitk
/usr/bin/gitk: 3: exec: wish: not found
> whereis wish
wish:
ない!
> sudo apt-get install tk8.6
> whereis wish
wish: /usr/bin/wish8.6
> sudo ln -s /usr/bin/wish8.6 /usr/bin/wish
> gitk
で動く
以下はgitwebのインストール
》make prefix=/usr gitweb
》sudo adduser git
git用のディレクトリを管理するユーザの作成
》sudo login git
》mkdir repositories
》mkdir www
》mkdir www/cgi-bin
》cd repositories
》git init --bare --shared=true test.git
》cd test.git
》nano description
新規作成プロジェクト名入力
》exit ---- git LOGOUT
》SUDOユーザLOGIN
》sudo make gitwebdir=/home/git/www/cgi-bin install-gitweb
》sudo nano /etc/gitweb.conf
新しく作成
......
# path to git projects (<project>.git)
$projectroot = "/home/git/repositories";
# directory to use for temp files
$git_temp = "/tmp";
# target of the home link on top of all pages
$home_link = $my_uri || "/";
# html text to include at home page
$home_text = "indextext.html";
# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;
# stylesheet to use
@stylesheets = ("static/gitweb.css");
# javascript code for gitweb
$javascript = "static/gitweb.js";
# logo to use
$logo = "static/git-logo.png";
# the 'favicon'
$favicon = "static/git-favicon.png";
# git-diff-tree(1) options to use for generated patches
#@diff_opts = ("-M");
@diff_opts = ();
$home_link_str = "Git.New";
$site_name = "GitWeb New";
$feature{'snapshot'}{'default'} = ['zip'];
...
》sudo nano /etc/apache2/conf-enabled/gitweb.conf
新しく作成
...
SetEnv GITWEB_CONFIG /etc/gitweb.conf
<Directory /home/*/www/cgi-bin>
Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi .sh .pl .php .exe
</Directory>
...
》sudo a2enmod userdir
》sudo nano /etc/apache2/mods-enabled/userdir.conf
内容の追加修正
---
<IfModule mod_userdir.c>
UserDir www/www
UserDir disabled root
ScriptAliasMatch ^/~([a-zA-Z0-9_-]+)/cgi-bin(.*) /home/$1/www/cgi-bin$2 <<===
<Directory /home/*/www/www>
AllowOverride FileInfo AuthConfig Limit
;;
;;
<Directory "/home/git/www/cgi-bin">
DirectoryIndex gitweb.cgi
AddHandler image/png .png
AddHandler text/css .css
AddHandler text/javascript .js
</Directory>
---
》sudo systemctl restart apache2
WEBブラウザで http://localhost/~git/cgi-bin/
gitアイコン、ボタンが出ればOK
......ファイルの関連.............
/etc/apache2/mods-enabled/userdir.conf
/etc/apache2/conf-enabled/gitweb.conf
/etc/gitweb.conf
/home/git/www/cgi-bin
├── gitweb.cgi
└── static
├── git-favicon.png
├── git-logo.png
├── gitweb.css
└── gitweb.js
(注意)Git add, commit
git レポジトリにGITから取ってきたディレクトリを入れ込んではいけない。
リモートにPUSHし、CLONEするとなくなっている。
どうするんだろう。
Shellスクリプトでチェックするくらいしか思いつかない。
---
ckdir=`tree -fa|grep -e "[^.]/\.git$" -e "[^.]/\.gitignore"`
if [ "$ckdir" != "" ]; then
echo "*?* " $ckdir
exit 1
fi
「UTF-8記号一覧」
UTF-8の記号① ② ③ ④ ⑤ ⑥ ⑦ なんかが欲しくなったので表にすることにした。
groffの中でもやっていたなと思って探したが見失った。いろいろ探してUNICODE規格V1.1 Appendix FのPDFが見つかった。変だなと思って誤記修正を探したが見つからなかった。
Linuxのファイルシステムのソースの中に正しいのが使われていた。以下に例題。
---
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
/* The Unicode Standard, version 1.1 -- Appendix F FSS-UTF より
* https://en.wikipedia.org/wiki/UTF-8
* http://www.unicode.org/versions/Unicode1.1.0/appF.pdf
*/
typedef
struct
{
int cmask;
int cval;
int shift;
long lmask;
long lval;
} Tab;
static
Tab tab[] =
{
{ 0x80, 0x00, 0*6, 0x7F, 0, }, /* 1 byte sequence */
{ 0xE0, 0xC0, 1*6, 0x7FF, 0x80, }, /* 2 byte sequence */
{ 0xF0, 0xE0, 2*6, 0xFFFF, 0x800, }, /* 3 byte sequence */
{ 0xF8, 0xF0, 3*6, 0x1FFFFF, 0x10000, }, /* 4 byte sequence */
{ 0xFC, 0xF8, 4*6, 0x3FFFFFF, 0x200000, }, /* 5 byte sequence */
{ 0xFE, 0xFC, 5*6, 0x7FFFFFFF, 0x4000000, }, /* 6 byte sequence */
{ 0, 0, 0, 0, 0 } /* end of table */
};
int
uut_mbtowc(wchar_t *p, char *s, size_t n)
{
long l;
int c0, c, nc;
Tab *t;
if(s == 0)
return 0;
nc = 0;
if(n <= nc)
return -1;
c0 = *s & 0xff;
l = c0;
for(t=tab; t->cmask; t++) {
nc++;
if((c0 & t->cmask) == t->cval) {
l &= t->lmask;
if(l < t->lval)
return -1;
*p = l;
return nc;
}
if(n <= nc)
return -1;
s++;
c = (*s ^ 0x80) & 0xFF;
if(c & 0xC0)
return -1;
l = (l<<6) | c;
}
return -1;
}
int
uut_wctomb(char *s, wchar_t wc)
{
long l;
int c, nc;
Tab *t;
if(s == 0)
return 0;
l = wc;
nc = 0;
for(t=tab; t->cmask; t++) {
nc++;
if(l <= t->lmask) {
c = t->shift;
*s = t->cval | (l>>c);
while(c > 0) {
c -= 6;
s++;
*s = 0x80 | ((l>>c) & 0x3F);
}
return nc;
}
}
return -1;
}
/* -----------------------------------*/
int main(void)
{
char ch[16];
unsigned long i;
size_t len;
char *utfchar = "あ";
wchar_t ucscode;
char *s;
s = setlocale(LC_CTYPE, "");
printf("%s\n", s);
len = uut_mbtowc(&ucscode, utfchar, 10);
if ( len <= 0 )
printf("UTF-8 変換エラー\n");
else
printf("入力:%s -> 出力:U+%04X-%lc \n", utfchar, ucscode, ucscode);
/*
* uut_wctomb()は、<locale.h> と 出力書式文字列 %lc で変換と同じことをする
*/
printf("------- UTF-8 英数、かな、カナ、記号コード表 --------");
for (i = 0U; i <= 0xFFFFU; i++) {
if ((i >= 0x00 && i < 0x20) ||
(i >= 0x7F && i < 0x2460) ||
(i >= 0x24eb && i < 0x300) ||
(i >= 0x27C0 && i < 0x3000 ) ||
(i >= 0x3100 && i < 0x3220 ) ||
(i >= 0x3400 && i < 0xE000 ) ||
// (i >= 0x4DB6 && i < 0x4E00 ) ||
// (i >= 0x9FA6 && i < 0xE000 ) ||
(i >= 0xE170 && i < 0xE200 ) ||
(i >= 0xE5A0 && i < 0xE680 ) ||
(i >= 0xE6B0 && i < 0xF5C0 ) ||
(i >= 0xF800 && i < 0xFE00 ) ||
// (i >= 0xF800 && i < 0xF900 ) ||
// (i >= 0xFA2E && i < 0xFE00 ) ||
(i >= 0xFE80 && i < 0xFF00 ) ||
(i >= 0xFFA0 && i < 0xFFE0) )
continue;
if( (i & 0x0f) == 0 ) printf("\nU+%04X: ", i);
len = uut_wctomb(ch, (unsigned short)i);
if (len > 0) {
ch[len] = '\0';
printf("%s ", ch);
}
}
printf("\n--------END-----------\n");
return 0;
}
---
おまけ、shellスクリプトでも同様にできるそうだ。
--------------------------------------
#!/bin/bash
# from https://unix.stackexchange.com/questions/337980/how-can-i-print-utf-8-and-unicode-tables-from-the-terminal
if [ "$1" = "" ]; then
echo $0 " [n/8]char code"
exit 0
fi
for y in $(seq 1 $1)
do
a=$(expr $y \* 8)
echo -n "$a "
for x in $(seq 0 7)
do
a=$(expr $y \* 8 + $x)
echo -ne "\\u$a "
done
echo
done
「shell script 引数1をAWKスクリプトに埋め込む」
nano t.sh
---
cat input.csv | awk -F, '$1~/'"$1"'/ {print "is good"}'
---
chmod +x t.sh
t.sh param-1
awk -F '$1~/raram-1/ {print "is good"}' になる
「chkconfig」
サービス起動の管理コマンド
(1)sudo apt-get install chkconfig
(2)chkconfig --list
「cp タイムスタンプも」
cp -p xxx bbb
「dig command」
1) sudo apt-get install dnsutils
「Full Path 表示」
ls -ld
-R で再帰呼び出し不可
tree -f
「port 番号とアプリを調べる」
$ sudo lsof -i:8888
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
pigpiod 479 root 0u IPv4 10532 0t0 TCP localhost:8888 (LISTEN)
$ sudo lsof -i:5353
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
avahi-dae 459 avahi 12u IPv4 11419 0t0 UDP *:mdns
avahi-dae 459 avahi 13u IPv6 11420 0t0 UDP *:mdns
$ sudo lsof -i:49545
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
avahi-dae 459 avahi 15u IPv6 11422 0t0 UDP *:49545
「shellスクリプトcgi」
http://192.168.1.xxx/cgi-bin/test.cgi?test=09
----
----test.cgi-----
#!/bin/sh
echo "Content-Type: text/plain"
echo
echo "p1:$QUERY_STRING"
-----
表示
p1:test=09
「ディレクトリだけ表示 tree」
tree -d
「ディレクトリ階層指定 tree」
tree -L 4
「パッケージ登録内容表示」
dpkg -L パッケージ名
「ブレース展開 csh, bash」
cp -p text.txt{,.old}
=> cp -p text.txt text.txt.old
「ユーザディレクトリの移動」
sudo usermod -d 移動先ディレクトリ -m ユーザ名
今までの内容をそのまま移動する
「ユーザ追加」
adduser --home ディレクトリ [--ingroup グループ名] ユーザ名
「壁紙のあるところ」
/usr/share/pixecl-wallpaper
「標準出力&エラー出力 標準出力」
cat test 2>&1
「標準出力&エラー出力をすてる」
echo "test" > /dev/null 2>&1