分类存档: Tech/技术-Archlinux - 第4页

备忘:Archlinux下玩flightgear

cd /usr/share/FlightGear/data/Aircraft
运行fgfs --aircraft=飞机名称,记住"--"是两个减号

可以自己下载更多的飞机模型放入这个目录中

Archlinux下用xmame+gmameui玩街机游戏

首先展示一下gmameui和彩京游戏

gmameui界面:

gmameui

彩京3界面:

cai_jing

安装配置方法:

安装mame:

yaourt -S xmame-x11

要是没有安装yaourt请先安装yaourt,再安装xmame,当然你也可以自己搜索xmame的源代码下载后编译安装,推荐使用yaourt,方便阿,不然自己下载编译的东西多了,自己又记不住难以进行有效管理,系统会很混乱。安装好后需要进行设置后,运行xmame才可以玩游戏了。archlinux安装的xmame没有默认的配置文件,我也懒得弄配置文件了,于是偷懒安装了个图形前端gmameui:

yaourt -S gmameui

运行gmameui后进行简单设置:

1 路径设置

一运行gmameui可能会出现对话框,要你选择路径

MAME executables要你选择xmame的路径,xmame在/usr/bin/xmame,点击add选择/usr/bin/xmame就行了

ROMs是要你选择游戏文件的目录,自己下载游戏文件,然后存到你喜欢的目录,然后add。你要是下载不到游戏rom我这里有几个,可以挂载网站上给大家共享,需要的联系我tootoogo@hotmail.com。

Samples可以不用管他。

弄好后,xmame会自动搜索可用的游戏,稍等片刻Avalibles ROMs中会出现可以玩得游戏

2 显示设置

Option->default option->display options

选择throttle, sleep when idle,

resolution里面是选择窗口长宽比例的

rotation使用来旋转屏幕的,要是玩彩京这种游戏,可以选择rotate left, do not apply rotation

Option->default option->effects & corrections

effects选择smooth scaling effect,不然图像会很小

Option->default option->vector

vector resolution 选择1024x768

3 输入设置

Option->default option->input

joystick type选择sdl joystick,记得在启动gmameui前插入joystick手柄,没有手柄就不用管这个选项

x11-input选择show cursor不然屏幕就没有鼠标了

Options->GMAMEUI preferences中

joystick device填/dev/hidraw1,你的手柄有可能是hidraw0 hidraw2等,自己试试看,没有手柄就不用管这个选项了

我的fvwm2配置文件

我配置的fvwm2主要是为了减少鼠标的操作,以求尽可能使用键盘满足大部分的工作需要。

主要功能键:

Ctrl + right   窗口最大化

Ctrl + Alt +up   窗口二分之一最大化并上移到屏幕顶部

Ctrl + Alt + down  窗口二分之一最大化并上移到屏幕顶部

Ctrl + Alt +left   窗口二分之一最大化并左移到屏幕左端

Ctrl + Alt + right  窗口二分之一最大化并右移到屏幕右端

Ctrl + Alt + a  窗口四分之一最大化并上移到屏幕顶部左上

Ctrl + Alt + b  窗口四分之一最大化并上移到屏幕顶部右上

Ctrl + Alt + c  窗口四分之一最大化并上移到屏幕顶部左下

Ctrl + Alt + d  窗口四分之一最大化并上移到屏幕顶部右下

Ctrl + Shift + a  鼠标上移到屏幕左上四分之一处

Ctrl + Shift + b  鼠标上移到屏幕右上四分之一处

Ctrl + Shift + c  鼠标上移到屏幕左下四分之一处

Ctrl + Shift + d  鼠标上移到屏幕右下四分之一处

Ctrl + Alt + f   切换虚拟桌面1

Ctrl + Alt + g  切换虚拟桌面2

Ctrl + Alt + r  将窗口移到虚拟桌面1

Ctrl + Alt + t  将窗口移到虚拟桌面2

Ctrl +Shift + q 当前窗口置于最底

Ctrl + left      者窗口最小化到标签

Ctrl + Shift + up 关闭窗口

Ctrl + Shift + Tab  启动xterm

该设置可能会与scim冲突,那么就修改下scim的快捷键吧。

我的配置文件.fvwm2rc如下:

# this is a bare bones sample .fvwm2rc/system.fvwm2rc file for fvwm.
# It should be customized before install.  See other sample .fvwm2rc files
# for hints, as well as pointers from the various links on the official
# fvwm web page (see the FAQ).

###EdgeResistance 250 10
###EdgeScroll 100 100
EdgeScroll 0 0
ClickTime 750

DeskTopSize 1x2

Menustyle * fvwm, Font -adobe-helvetica-bold-r-normal--*-100-*-*-*-*-*-*
MenuStyle * Foreground maroon, Background grey60, Greyed grey40

ColormapFocus FollowsMouse

# default Styles:
# make sure these fonts exist on your system:
Style *           Font -adobe-helvetica-bold-r-normal--*-130-*-*-*-*-*-*

Style *           IconFont -adobe-helvetica-bold-r-normal--*-150-*-*-*-*-*-*
Style *           HilightFore black, HilightBack palevioletred
Style *           BorderWidth 7, HandleWidth 7
Style *           Icon unknown1.xpm, Color lightgrey/dimgrey
Style *           MWMFunctions, MWMDecor, HintOverride
Style *           DecorateTransient, NoPPosition
Style *           IconBox 0 -10 -280 -1
Style *           FocusFollowsMouse
#Style *           TileCascadePlacement
Style *           MinOverlapPercentPlacement

# Styles for various Fvwm modules:
Style "Fvwm*"       NoTitle,  Sticky, WindowListSkip
Style "Fvwm*"       BorderWidth 2, CirculateSkipIcon, CirculateSkip
Style "FvwmPager"   StaysOnTop
Style "FvwmBanner"  StaysOnTop
Style "FvwmButtons" Icon toolbox.xpm, ClickToFocus

# Styles for your common terminal emulator programs:
Style "XTerm"       Icon xterm.xpm, SloppyFocus, IconBox -70 1 -1 -140
Style "rxvt"        Icon term.xpm, SloppyFocus, IconBox -70 1 -1 -140
Style "rxvt"        MWMBorder, MWMButtons

# Styles for various common programs:
Style "*lock"       NoTitle, NoHandles, Sticky, WindowListSkip, ClickToFocus
Style "xbiff"       NoTitle, Sticky, WindowListSkip, ClickToFocus
Style "xcalc"       Icon xcalc.xpm, NoButton 2,ClickToFocus
Style "xmh"         Icon mail1.xpm, NoIconTitle,StickyIcon
Style "xmh"        NoButton 2
Style "xman"        Icon xman.xpm, ClickToFocus
Style "xmag"        Icon mag_glass.xpm, ClickToFocus
Style "xgraph"      Icon graphs.xpm, ClickToFocus
Style "xmosaic"     Color Green/Yellow, ClickToFocus

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

AddToFunc    MyUpSmall
+ I        Resize    98    48
+ I        Move    0    0
+ I        WindowId root 1 WarpToWindow 50 25
+ I        Raise

AddToFunc    MyDownSmall
+ I        Resize    98    45
+ I        Move    0    52
+ I        WindowId root 1 WarpToWindow 50 75
+ I        Raise

AddToFunc    MyLeftSmall
+ I        Resize    48    96
+ I        Move    0    0
+ I        WindowId root 1 WarpToWindow 25 50
+ I        Raise

AddToFunc    MyRightSmall
+ I        Resize    48    96
+ I        Move    49    0
+ I        WindowId root 1 WarpToWindow 75 50
+ I        Raise

AddToFunc    MyUp22
+ I        Resize    48    47
+ I        Move    49    50
+ I        WindowId root 1 WarpToWindow 75 75
+ I        Raise
AddToFunc    MyUp21
+ I        Resize    48    47
+ I        Move    0    50
+ I        WindowId root 1 WarpToWindow 25 75
+ I        Raise
AddToFunc    MyUp12
+ I        Resize    48    47
+ I        Move    49    0
+ I        WindowId root 1 WarpToWindow 75 25
+ I        Raise
AddToFunc    MyUp11
+ I        Resize    48    47
+ I        Move    0    0
+ I        WindowId root 1 WarpToWindow 25 25
+ I        Raise
AddToFunc    MyMaximize
+    I    Maximize
+ I        Raise
# some simple default key bindings:
#Key Next         A       SCM     Next (AcceptsFocus) Focus
#Key Prior        A       SCM     Prev (AcceptsFocus) Focus
Key Right     A     C     MyMaximize
Key Left     A     C     Iconify toggle
Key Up         A     SC     Close
Key Up         A     SMC     Delete

Key Tab         A     SC     Exec exec xterm
Key =         A     SC     Exec exec mixer pcm +5
Key -         A     SC     Exec exec mixer pcm -5

#Key Up         A     C     PackWrapperRight
#Key Down     A     C     Prev (AcceptsFocus) Focus
Key t          A     SC     MoveToPage 1 1
Key r         A     SC     MoveToPage 0 0
Key g         A      SC     GotoPage   1 1
Key f         A     SC     GotoPage   0 0

Key a         A     MC     MyUp11
Key b         A     MC     MyUp12
Key c         A     MC     MyUp21
Key d         A     MC     MyUp22

Key a         A     SC     WindowId root 1 WarpToWindow 25 25
Key b         A     SC     WindowId root 1 WarpToWindow 75 25
Key c         A     SC     WindowId root 1 WarpToWindow 25 75
Key d         A     SC     WindowId root 1 WarpToWindow 75 75

Key q         A     SC     Lower

Key Up         A     MC     MyUpSmall
Key Down     A     MC     MyDownSmall
Key Left     A     MC     MyLeftSmall
Key Right     A     MC     MyRightSmall
Key m         A     MC     All Iconify true
Key Tab         A     M WindowList c c CurrentAtEnd, IconifiedAtEnd
Key =         A     SC     Exec mixer pcm +5
Key -         A     SC     Exec mixer pcm -5

# some simple default mouse bindings:
#   for the root window:
Mouse 1    R       A       Menu RootMenu Nop
Mouse 2    R        A          Menu Window-Ops Nop
Mouse 3    R        A          WindowList

#   for the title bar buttons:
Mouse 0    1        A          Menu Window-Ops2 Close
Mouse 0    2        A         Maximize-Func
Mouse 0    4        A         Iconify

#   for other parts of the window/borders/icons:
Mouse 1    F    A    Resize-or-Raise
Mouse 1    TS    A    Move-or-Raise
Mouse 1    I    A    Move-or-Iconify
Mouse 2    I    A    Iconify
Mouse 2    FST    A    Menu Window-Ops2 Nop
Mouse 3    TSIF    A    RaiseLower

######################## Initialization Functions ############################
AddToFunc StartFunction
+ I Module FvwmButtons

#AddToFunc InitFunction
# + I exec xsetroot -mod 2 2 -fg rgb:55/40/55 -bg rgb:70/50/70

# For some SM-s (like gnome-session) there is an internal background setter.
AddToFunc SessionInitFunction
+ I Nop
#AddtoFunc InitFunction
#+ I Exec exec /usr/bin/gnome-settings-daemon

######################## Menus ###################
AddToMenu RootMenu    "Root Menu"    Title
+            "XTerm"        Exec exec xterm
+            "Rxvt"        Exec exec rxvt
+            ""        Nop
+            "Remote Logins"    Popup Remote-Logins
+            ""        Nop
+                       "Utilities"     Popup Utilities
+            ""        Nop
+            "Fvwm Modules"              Popup Module-Popup
+                       "Fvwm Window Ops"         Popup Window-Ops
+                       "Fvwm Simple Config Ops"  Popup Misc-Ops
+            ""        Nop
+                       "Refresh Screen"   Refresh
+                       "Recapture Screen" Recapture
+            ""        Nop
+            "Exit Fvwm"    Popup Quit-Verify

AddToMenu Utilities     "Utilities" Title
+            "Top"        Exec exec xterm -T Top -n Top -e top
+            "Calculator"    Exec exec xcalc
+            "Xman"        Exec exec xman
+            "Xmag"        Exec exec xmag
+                       "Editres"       Exec exec editres
+            ""        Nop
+            "XEmacs"    Exec exec xemacs
+                       "Mail"          MailFunction xmh "-font fixed"
+            ""        Nop
+                       "XLock"         Exec exec xlock -mode random
+            ""        Nop
+                       "Reset X defaults" Exec xrdb -load $HOME/.Xdefaults

AddToMenu Misc-Ops "Misc Config Opts" Title
+                  "Sloppy Focus"        ChangeDefaultFocus SloppyFocus
+                  "Click To Focus"      ChangeDefaultFocus ClickToFocus
+                  "Focus Follows Mouse" ChangeDefaultFocus FocusFollowsMouse
+                  "" Nop
+                  "Colormap Follows Mouse" ColormapFocus FollowsMouse
+                  "Colormap Follows Focus" ColormapFocus FollowsFocus
+                  "" Nop
+                  "Full Paging ON"         EdgeScroll 100 100
+                  "All Paging OFF"         EdgeScroll 0 0
+                  "Horizontal Paging Only" EdgeScroll 100 0
+                  "Vertical Paging Only"   EdgeScroll 0 100
+                  "Partial Paging"         EdgeScroll 50 50
+                  "Full Paging && Edge Wrap" EdgeScroll 100000 100000

AddToMenu Window-Ops    "Window Ops"    Title
+            "Move"        Move
+            "Resize"    Resize
+            "Raise"        Raise
+            "Lower"        Lower
+             "(De)Iconify"    Iconify
+            "(Un)Stick"    Stick
+            "(Un)Maximize"    Maximize
+            ""        Nop
+            "Delete"    Delete
+            "Close"        Close
+            "Destroy"    Destroy
+            ""        Nop
+            "Refresh Window" RefreshWindow

AddToMenu Window-Ops2    "&Move"        Move
+            "&Resize"    Resize
+            "R&aise"    Raise
+            "&Lower"    Lower
+            "(De)&Iconify"    Iconify
+            "(Un)&Stick"    Stick
+                       "(Un)Ma&ximize" Maximize
+            ""        Nop
+            "&Delete"    Delete
+            "&Close"    Close
+            "Destroy"    Destroy
+            ""        Nop
+            "ScrollBar"     Module FvwmScroll 2 2
+            "Print"         PrintFunction
+                       "Print Reverse" PrintReverseFunction

# be sure to fill these in with your correct machine names:
AddToMenu Remote-Logins    "dopey"     Exec rsh dopey rxvt -display $HOSTDISPLAY &
+            "snoopy" Exec rsh snoopy rxvt -display $HOSTDISPLAY &
+            "grumpy" Exec rsh grumpy rxvt -display $HOSTDISPLAY &
+            "happy"     Exec rsh happy rxvt -display $HOSTDISPLAY &
+            "bailey" Exec rsh bailey rxvt -display $HOSTDISPLAY &
+            "barnum" Exec rsh barnum rxvt -display $HOSTDISPLAY &
+            "joker"     Exec rsh joker rxvt -display $HOSTDISPLAY &
+            "signal" Exec rxterm signal

AddToMenu Module-Popup    "FvwmModules"    Title
+            "Identify"    Module    FvwmIdent
+            "Talk"      Module    FvwmTalk
+            ""        Nop
+            "Button-Bar"    Module    FvwmButtons
+            "Pager"        Module  FvwmPager 0 0
+            "Pager (2 desks)" Module  FvwmPager 0 1
+            "WinList"    Module  FvwmWinList
+            ""        Nop
+            "Banner"    Module    FvwmBanner
+                       "ScrollBar"     Module  FvwmScroll 50 50
+            "Background"    Module  FvwmBacker
+                       "AutoRaise"     Module  FvwmAuto 200 Raise Nop
+                       "Stop AutoRaise" KillModule FvwmAuto
+            ""        Nop
+            "IconBox"    Module    FvwmIconBox
+                       "IconMan"       Module  FvwmIconMan
+            ""        Nop
+                       "Form - Rlogin"      Module FvwmForm Rlogin
+                       "Form - MyFvwmTalk"  Module FvwmForm MyFvwmTalk
+                       "Form - QuitVerify"  Module FvwmForm QuitVerify

AddToMenu Quit-Verify     "Really Quit Fvwm?" Title
+                  "Yes, Really Quit"  Quit
+                  ""            Nop
+                       "Restart Fvwm"      Restart
+                  "Restart Fvwm 1.x"  Restart fvwm -s
+                  ""            Nop
+                  "Start twm"         Restart twm
+                  "Start ctwm"        Restart ctwm
+                "Start tvtwm"       Restart tvtwm
+                "Start vtwm"        Restart vtwm
+                  "Start mwm"            Restart mwm
+                        "Start olwm"        Restart /usr/openwin/bin/olwm
+                  ""            Nop
+                  "Start dummy"       Restart xterm
+                  ""            Nop
+                  "No, Don't Quit"    Nop

######################## Sample Functions ##########################

AddToFunc MailFunction       I Next (AcceptsFocus $0) Iconify -1
+                   I Next (AcceptsFocus $0) Focus
+               I None (AcceptsFocus $0) Exec $0 $1

AddToFunc Move-or-Raise        I Raise
+                M Move
+                  D Lower

AddToFunc Move-or-Raise2    M Raise
+                M Move
+                  D Lower

AddToFunc Maximize-Func        M Maximize     0 100
+                C Maximize     0 80
+                D Maximize     100 100

AddToFunc Move-or-Iconify    I Raise
+                M Move
+                D Iconify

AddToFunc Resize-or-Raise    I Raise
+                M Resize
+                D Lower

AddToFunc Resize-or-Raise2    M Raise
+                M Resize
+                D Lower

AddToFunc PrintFunction        I Raise
+                I Exec xdpr -id $w

AddToFunc PrintReverseFunction  I Raise
+                               I Exec xdpr 1/2 -h -rv -id $w

AddToFunc Iconify-and-Raise     I Iconify
+                               I Raise

# RLOGIN machine fg bg
AddToFunc RLOGIN I Exec xterm -fg $1 -bg $2 -e rlogin $0 -8

# TELNET machine fg bg
AddToFunc TELNET I Exec xterm -fg $1 -bg $2 -e telnet $0

AddToFunc FocusAndWarp I Focus
+                      I WarpToWindow 2p 2p

AddToFunc DeiconifyFocusAndWarp I Iconify -1
+                               I FocusAndWarp

AddToFunc ChangeDefaultFocus I Style * $0
+                            I Recapture
################## FvwmButtons button-bar ################################
*FvwmButtonsGeometry 500x65-1-1
*FvwmButtonsBack bisque3
*FvwmButtons(Frame 2 Padding 2 2 Container(Rows 4 Columns 10 Frame 1 \
Padding 10 0))
*FvwmButtons(8x2 Frame 2 Swallow "FvwmIconMan" "Module FvwmIconMan")
*FvwmButtons(1x2 Frame 2 Swallow(UseOld) "FvwmPager" "Module FvwmPager 0 0")
*FvwmButtons(1x2 Frame 0 Container(Rows 2 Columns 2 Frame 0))
#*FvwmButtons(Frame 2 Swallow(UseOld,NoHints,Respawn) "xbiff" `Exec exec xbiff -bg bisque3`)
*FvwmButtons(2x1 Frame 3 Swallow(UseOld,NoHints,Respawn) "xclock" `Exec exec xclock -d -brief -bg bisque3 -fg black -hd black -hl black -padding 0 -update 1`)
*FvwmButtons(2x1 Frame 2 Swallow(UseOld,NoHints,Respawn) "xload" `Exec exec xload -bg bisque3 -fg black -update 5 -nolabel`)
*FvwmButtons(End)
*FvwmButtons(End)

########################## Icon Manager ####################################
# this FvwmIconMan setup is for swallowing in above button bar example
*FvwmIconMan*numManagers 1
*FvwmIconMan*Resolution  page
*FvwmIconMan*background  bisque3
*FvwmIconMan*foreground  black
*FvwmIconMan*font        7x13bold
*FvwmIconMan*format      "%t"
*FvwmIconMan*action      Mouse   1 N sendcommand Focus, sendcommand "Iconify"
*FvwmIconMan*action      Mouse   2 N sendcommand "Iconify 1"
*FvwmIconMan*action      Mouse   3 N sendcommand "FvwmIdent"
*FvwmIconMan*followfocus true
#*FvwmIconMan*sort        name

*FvwmIconMan*plainbutton          up black bisque3
*FvwmIconMan*selectbutton         down black bisque3
*FvwmIconMan*focusbutton          up yellow firebrick
*FvwmIconMan*focusandselectButton down yellow firebrick
*FvwmIconMan*dontshow icon=Untitled title=Untitled
#*FvwmIconMan*drawicons true
*FvwmIconMan*buttongeometry  300x0
*FvwmIconMan*managergeometry 1x5
*FvwmIconMan*sort Id
########################## Window-Identifier ###############################
# Just choose colors and a fonts
*FvwmIdentBack MidnightBlue
*FvwmIdentFore Yellow
*FvwmIdentFont -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*

########################### Pager #########################################
*FvwmPagerBack #908090
*FvwmPagerFore #484048
#*FvwmPagerFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
# turn off desktop names for swallowing in above button bar example:
*FvwmPagerFont none
*FvwmPagerHilight #cab3ca
*FvwmPagerGeometry -1-1
*FvwmPagerLabel 0 Misc
*FvwmPagerLabel 1 Maker
*FvwmPagerLabel 2 Mail
*FvwmPagerLabel 3 Matlab
*FvwmPagerSmallFont 5x8
*FvwmPagerBalloons            All
*FvwmPagerBalloonBack         Yellow
*FvwmPagerBalloonFore         Black
*FvwmPagerBalloonFont         lucidasanstypewriter-12
*FvwmPagerBalloonYOffset      +2
*FvwmPagerBalloonBorderWidth  1
*FvwmPagerBalloonBorderColor  Black

##########################FvwmWinList##################################
*FvwmWinListBack #908090
*FvwmWinListFore Black
*FvwmWinListFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
*FvwmWinListAction Click1 Iconify -1,Focus
*FvwmWinListAction Click2 Iconify
*FvwmWinListAction Click3 Module "FvwmIdent" FvwmIdent
*FvwmWinListUseSkipList
*FvwmWinListGeometry +0-1

*FvwmBackerDesk 0 -solid steelblue
*FvwmBackerDesk 1 -solid midnightblue

*FvwmScrollBack grey40
*FvwmScrollFore green

############################################################
############################################################
# Note that icons are shown in the module
#    only if NoIcon commnand is applied.
Style     *  NoIcon

############################################################
*FvwmIconBoxIconBack    #cfcfcf
*FvwmIconBoxIconHiFore  black
*FvwmIconBoxIconHiBack  LightSkyBlue
*FvwmIconBoxBack        #5f9ea0
#*FvwmIconBoxFore       blue
*FvwmIconBoxGeometry    5x1+0+0
*FvwmIconBoxMaxIconSize 64x38
*FvwmIconBoxFont        -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*
*FvwmIconBoxSortIcons   IconName
*FvwmIconBoxPadding     4
*FvwmIconBoxLines       10
*FvwmIconBoxSBWidth     11
*FvwmIconBoxPlacement   Left Top
*FvwmIconBoxPixmap      fvwm.xpm
#*FvwmIconBoxHideSC Horizontal
*FvwmIconBoxSetWMIconSize
*FvwmIconBoxHilightFocusWin
#*FvwmIconBoxResolution          Desk
*FvwmIconBoxMouse       1       Click           RaiseLower
*FvwmIconBoxMouse       1       DoubleClick     Iconify
*FvwmIconBoxMouse       2       Click           Iconify -1, Focus
*FvwmIconBoxMouse       3       Click           Module FvwmIdent
*FvwmIconBoxKey         r       RaiseLower
*FvwmIconBoxKey         space   Iconify
*FvwmIconBoxKey         d       Close
*FvwmIconBoxKey         n       Next
*FvwmIconBoxKey         p       Prev
*FvwmIconBoxKey         h       Left
*FvwmIconBoxKey         j       Down
*FvwmIconBoxKey         k       Up
*FvwmIconBoxKey         l       Right

#
# Icon file specifications
#
# Mostly, you don't have to specify icon files, as FvwmIconBox now
# reads icon files specified in Style commands.
#
*FvwmIconBox            "Fvwm*"         -

# FvwmForm alias - rlogin or telnet to host via xterm
*RloginWarpPointer
*RloginFont         *helvetica*m*r*n*12*
*RloginButtonFont   *helvetica*m*o*n*12*
*RloginInputFont    *cour*m*r*n*12*
*RloginFore         Black
*RloginBack         Light Gray
*RloginItemFore          Wheat
*RloginItemBack          Gray50
# begin items
*RloginLine         center
*RloginText         "Login to Remote Host"
*RloginLine         center
*RloginText         "Host:"
*RloginInput        HostName  30   ""
*RloginLine         center
*RloginSelection    meth single
*RloginChoice       TN TN off "telnet"
*RloginChoice       RL RL on "rlogin"
*RloginSelection    UserSel   single
#*RloginChoice       Default   Default   on   "same user"
#*RloginChoice       Custom    Custom    off  "user:"
*RloginText         "(Userid:"
*RloginInput        UserName  10   ""
*RloginText         ")"
*RloginLine         center
*RloginText         "FG:"
*RloginInput        FgColor 15 ""
*RloginText         "BG:"
*RloginInput        BgColor 15 ""
*RloginLine         expand
*RloginButton       quit "Login" ^M
*RloginCommand Exec xterm  $(FgColor?-fg $(FgColor)) $(BgColor?-bg $(BgColor)) -T xterm@$(HostName) -e $(RL?rlogin) $(TN?telnet) $(HostName) $(RL?-8 $(UserName?-l $(UserName)))
*RloginButton       restart   "Clear"
*RloginCommand Beep
*RloginButton       quit "Cancel"
*RloginCommand Nop

# FvwmForm alias - query exit ala mwm
*QuitVerifyGrabServer
*QuitVerifyWarpPointer
*QuitVerifyFont          *helvetica*m*r*n*14*
#*QuitVerifyButtonFont    *helvetica*m*o*n*14*
*QuitVerifyButtonFont    7x13bold
*QuitVerifyFore          Black
*QuitVerifyBack          Light Gray
*QuitVerifyItemFore Wheat
*QuitVerifyItemBack Gray50
# begin items
*QuitVerifyLine          center
*QuitVerifyText          "Do you really want to exit FVWM?"
*QuitVerifyLine          expand
*QuitVerifyButton   quit      " Exit "
*QuitVerifyCommand  Quit
*QuitVerifyButton   quit      "Cancel"
*QuitVerifyCommand  Nop

# MyTalk & MyFvwmTalk from Dave Goldberg
# MyTalk Form - dissappears after use
*MyTalkWarpPointer
*MyTalkFont *helvetica*m*r*n*14*
*MyTalkButtonFont *helvetica*m*o*n*14*
*MyTalkInputFont *cour*m*r*n*14*
*MyTalkFore Red
*MyTalkBack Gray
*MyTalkItemFore Blue
*MyTalkItemBack Gray
*MyTalkLine center
*MyTalkText "Fvwm Function"
*MyTalkInput Func 40 ""
*MyTalkLine expand
*MyTalkButton quit "Run" ^M
*MyTalkCommand $(Func)
*MyTalkButton restart "Clear" ^R
*MyTalkButton quit "Cancel" ^C
*MyTalkCommand Nop
# MyFvwmTalk Form - sticks around
*MyFvwmTalkWarpPointer
*MyFvwmTalkFont *helvetica*m*r*n*14*
*MyFvwmTalkButtonFont *helvetica*m*o*n*14*
*MyFvwmTalkInputFont *cour*m*r*n*14*
*MyFvwmTalkFore Red
*MyFvwmTalkBack Gray
*MyFvwmTalkItemFore Blue
*MyFvwmTalkItemBack Gray
*MyFvwmTalkLine center
*MyFvwmTalkText "Fvwm Function"
*MyFvwmTalkInput Func 40 ""
*MyFvwmTalkLine expand
*MyFvwmTalkButton restart "Run" ^M
*MyFvwmTalkCommand $(Func)
*MyFvwmTalkButton restart "Clear" ^R
*MyFvwmTalkCommand Nop
*MyFvwmTalkButton restart "Iconify" ^Z
*MyFvwmTalkCommand Next [MyFvwmTalk] Iconify
*MyFvwmTalkButton quit "Quit" ^C
*MyFvwmTalkCommand Nop

# to change banner pixmap
#*FvwmBannerPixmap fvwm3.xpm
#*FvwmBannerTimeout 2

我的twm配置文件以及更换桌面背景

我配置的twm主要是为了减少鼠标的操作,以求尽可能使用键盘满足大部分的工作需要。twm默认的桌面背景很丑陋,在Freebsd下可以采用xli更换桌面背景,ArchLinuc下可以用feh更换背景。

例如在ArchLinux下更换背景:

feh --bg-scale /usr/share/archlinux/wallpaper/archlinux-carbonite-knight.jpg&

可以将上面命令写入.xinitrc中这样每次启动自动设置背景。

注意:如果你发现你的twm或者fvwm启动很慢,那么就把环境变量LANG、LC_TYPE、LC_ALL等设置为zh_CN.gb2312,因为twm和fvwm对其他汉字字符集支持的不够好。

该设置可能会与scim冲突,那么就修改下scim的快捷键吧。

我的twm主要快捷键定义如下:

Ctrl + right   窗口最大化

Ctrl + up       标签上移

Ctrl + down  标签下移

Ctrl + left      标签还原到窗口,或者窗口最小化到标签

Ctrl + Shift + up 关闭窗口

Ctrl + Shift + Tab  启动xterm

配置文件.twmrc如下:

#保存为.twmrc,并放置于用户根目录下

#AutoRaise {"iconmgr"}
RightTitleButton "/usr/X11R6/include/X11/bitmaps/term"=f.menu "defops"
RightTitleButton "/usr/X11R6/include/X11/bitmaps/boxes"=f.resize
LeftTitleButton "/usr/X11R6/include/X11/bitmaps/dot"=f.iconify
LeftTitleButton "/usr/X11R6/include/X11/bitmaps/cross_weave"=f.fullzoom
LeftTitleButton "/usr/X11R6/include/X11/bitmaps/xm_hour16"=f.delete
#ResizeFont    "*new century schoolbook-medium-i-*--24-*-iso8859-*"
#IconManagerFont    "*new century schoolbook-medium-r-*--12-*-iso8859-*"
#MenuFont    "*new century schoolbook-medium-r-*--18-*-iso8859-*"
#TitleFont    "*new century schoolbook-medium-r-*--14-*-iso8859-*"
#IconFont    "*new century schoolbook-medium-r-*--12-*-iso8859-*"
#DoorFont    "*new century schoolbook-medium-r-*--12-*-iso8859-*"

TitleFont "-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*"
ResizeFont "-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*"
MenuFont "-adobe-helvetica-bold-r-normal--*-100-*-*-*-*-*-*"
IconFont "-adobe-helvetica-bold-r-normal--*-100-*-*-*-*-*-*"
IconManagerFont "-adobe-helvetica-bold-r-normal--*-100-*-*-*"

IconifyByUnMapping
#don't show icon on desktop
RandomPlacement
AutoRelativeResize
NoGrabServer
RestartPreviousState
DecorateTransients
NoCaseSensitive
NoDefaults
MaxWindowSize "30000x30000"
#where to put icon an d how to place them
#IconRegion "140x684+0+0" North East 130 90 {}
#IconRegion "800x600+0+0" North West 10 10
IconRegion "800x600+0+0" South East 10 10
#ClientBorderWidth

#IconManagerGeometry "1024x20+0-0" 20
IconManagerGeometry "70x1-0+0" 1
ForceIcons
ShowIconManager
#SortIconManager
NoTitle {"IconManger"}
BorderWidth 4
IconBorderWidth 2
FramePadding 0
NoTitle {"TWM Icon Manager"}
NoTitleHighlight {"TWM Icon Manager"}
NoHighlight {"TWM Icon Manager"}
NoRaiseOnWarp
UsePPosition "on"
#NoRaiseOnDeiconify
#WarpUnmapped
#WarpCursor
TitleButtonBorderWidth 1
Cursors{

IconMgr "sb_left_arrow"
Frame  "hand2"

}

Color
{

BorderColor "rgb:e/7/7" {"TWM Icon Manager" "gray0"}
BorderTileBackground "gray0"
BorderTileForeground "gray60"
DefaultBackground "rgb:2/a/9"

DefaultForeground "gray45"
#TitleBackground "rgb:2/a/9"

#TitleBackground "LightSteelBlue"
TitleBackground "black"
#TitleForeground "gray0"
TitleForeground "gray85"

#    MenuBackground "rgb:2/a/9"
MenuBackground "black"
MenuForeground "gray85"
#MenuForeground "gray5"
MenuBorderColor "slategrey"
MenuTitleBackground "gray70"
MenuTitleForeground "rgb:2/a/9"
#   IconBackground "LightSteelBlue"
IconBackground "black"
#    IconForeground "gray0"
IconForeground "gray85"
IconBorderColor "gray5"
#   IconManagerBackground "LightSteelBlue"
IconManagerBackground "black"
IconManagerForeground "gray85"
#    IconManagerForeground "gray0"
IconManagerHighlight    "rgb:f/0/0"

}
NoStackMode {}

IconManagerDontShow {"TWM Icon Manager"}
#
# Define some useful functions for motion-based actions.
#
DefaultFunction f.beep
WindowFunction f.deiconify
MoveDelta 3
Function "downiconmgr-or-raise" {  f.downiconmgr}
Function "upiconmgr-or-raise" {f.upiconmgr   }
Function "iconify-or-raise" {f.iconify f.warptoiconmgr ""}
Function "move-or-lower" { f.move f.deltastop f.lower }
Function "move-or-raise" {
f.move
#f.deltastop
f.raise
}
Function "move-or-iconify" { f.move f.deltastop f.iconify }

#
# Set some useful bindings.  Sort of uwm-ish, sort of simple-button-ish
#
Button1 = : root : f.menu "defops"
Button1    = :frame: f.resize
Button3 = :icon:f.delete
Button3 = s : title : f.showiconmgr
Button1 = : title : f.function "move-or-raise"
Button3= :title:f.iconify
Button1=c:title:f.fullzoom
Button1 = : icon : f.function "move-or-icon"
Button2 = : icon : f.iconify

Button1 = : iconmgr : f.iconify
Button1=s:   iconmgr    :f.delete
Button3 = : iconmgr : f.delete
"F12"      =m:all:f.iconify
"F11"    =m:all:f.fullzoom
"F9"    =m:all:f.delete

"Right"    =c:all:f.fullzoom

"Down"    =c :all:f.function "downiconmgr-or-raise"
#"Up"    =c :all:f.backiconmgr
"Up"    =c :all:f.function "upiconmgr-or-raise"
#"Down"    =c :all:f.forwiconmgr
#"Left"    =c s:all:f.hideiconmgr
#"Right"    =c s:all:f.showiconmgr
"Left"  =c :all: f.function "iconify-or-raise"
"Right"  =c :all: f.fullzoom
"Up"     =c s:all:f.delete
"F5"    =m:    all:f.winrefresh
"Tab"     =c s:all:f.exec "exec xterm -fn -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1 -geometry 80x19  -fg black -bg white &"

#"Tab"     =c s:all:f.exec "exec mlterm -g 80x19 &"

#"Left"  =m :all:f.raise
#
# And a menus with the usual things
#

menu "Program"
{

"firefox"    f.exec    "exec firefox3&"
"opera"        f.exec    "exec opera&"
"emacs"        f.exec    "exec emacs&"
"xmms"    f.exec    "exec xmms&"
"gmplayer"    f.exec    "exec gmplayer&"
"nautilus"    f.exec "nautilus --no-desktop&"
}
menu "System"
{

"Show IconMgr"  f.showiconmgr
"Hide IconMgr"    f.hideiconmgr
"Kill"        f.destroy
""        f.nop
#"VTWM"        f.startwm "vtwm"
"Restart"    f.restart

"Exit X"        f.quit
}
menu "defops"
{
#"Twm"    f.title
#"Iconify"    f.iconify
#"Resize"    f.resize
#"Move"        f.move
#"Raise"        f.raise
#"Lower"        f.lower
#""        f.nop
#"Focus"        f.focus
#"Unfocus"    f.unfocus
#"IcnMgr"    f.showiconmgr
#"Min"    f.iconify
#"Max"    f.fullzoom
man#"Exit"    f.delete
#"Hide Iconmgr"    f.hideiconmgr
#""        f.nop
#"Xterm"        f.exec "exec xterm -geometry 90x25 -fn 9x15 -fg gray -bg black &"

"Time"        f.exec "exec xmessage `date`&"
""        f.nop
"Prog"    f.menu "Program"

""        f.nop
"System" f.menu "System"

#"scim"        f.exec "exec scim -d"
#"emacs"        f.exec "exec emacs &"
#"wine opera"    f.exec "exec ./w_opera"
#"opera"        f.exec "exec opera &"

#"Delete"    f.delete
#""        f.nop

#"0"        f.warptoscreen "0"
#"1"        f.warptoscreen "1"
#"warp"        f.warpring "next"
}

Archlinux下mjpg_streamer+usb摄像头实现网页远程视频监控

发现mjpg-streamer自带了http服务,可以通过网页浏览usb摄像头拍摄的实时画面,可以用来进行网络视频监控,于是就折腾了一下,下面把具体方法介绍一下

1 安装mjpg-streamer

yaourt -S mjpg-streamer-uvc

我用的是logitech c210摄像头,用其他的摄像头可以安装mjpg-streamer

2 开启mjpg-streamer服务

插入摄像头&开启mjpg_streamer:

mjpg_streamer -o "output_http.so -w /srv/http"

然后在自己或别人的电脑上,打开浏览器输入

http://你的服务器ip:8080

或者在本地监控,输入http://127.0.0.1:8080/?action=stream

则会看到一个网页,点击stream或者java就可以看到监控视频了,据说java可以支持大部分浏览器,通用性较好。

注意:上面的命令默认使用的是mjpeg格式读取摄像头,而大部分摄像头采用的是YUV格式,我是用的是罗技的摄像头支持mjpge所以使用无问题,如果使用不支持mjpge的摄像头需要更改参数,下面这个例子支持yuv模式,和密码访问:

mjpg_streamer -i "input_uvc.so -f 15 -r 640x480 -y" -o "output_http.so -w /usr/share/mjpeg-streamer/www -p 8080 -c username:password"

-p 指定端口号

-y指定YUV模式

-f指定帧率

-r 图像尺寸

-c 指定用户名和密码

mjpg_streame的input_file.so还支持从某个指定的文件夹将图片(其他程序生成的)上传、浏览的功能,他会检测该文件夹中新出现的图像文件,不断地进行上传

output_file.so支持将图片存储的功能,可以指定时间间隔

例如:

./mjpg_streamer -i "input_file.so -f /tmp/input -r" -o "output_http.so -w www"

将目录/tmp/input中的图像不断上传

./mjpg_streamer -o "output_http.so -w `pwd`/www" -o "output_file.so -f pics -d 15000"

将视频上传到web服务,并以1.5秒每帧的速度保存文件到当前文件夹

./mjpg_streamer --input "input_uvc.so --help"
查看帮助,input_uvc.so可以换成,input_file.so, output_file.so等

就可以了。

我的服务器是FreeBSD8.1改天看看把这个方法搬到我的服务器上玩玩

GraphicsMagick图像处理系统使用方法

用linux一段时间了,不知道怎么在linux下截屏,搜了一下,最简单的方法就是用命令:

import a.jpg

然后用鼠标选择截屏区域即可,所截屏报存在a.jpg中,import是ImageMagick中的一个命令,要使用他要先安装ImageMagick。不过我找到了GraphicsMagick,和ImageMagick类似,感觉很好。

GraphicsMagick是一个Linux下的图像处理系统,最初起源于ImageMagick,可以支持几乎所有的图像格式,能够进行图像格式转换、处理等工作,号称图像处理中的瑞是军刀。据说其工作效率比ImageMagick要高,GraphicsMagick主页是:http://www.graphicsmagick.org/上面有详细的GraphicsMagick和ImageMagick的性能对比。

下面给出一些常用的GraphicsMagick的使用方法:

0. 显示图像文件详细信息

gm identify a.jpg

1.更改当前目录下*.jpg的尺寸大小,并保存于目录.thumb里面

gm mogrify -output-directory .thumbs -resize 320x200 *.jpg

2. 将三幅图像和并为一副图像

gm montage -mode concatenate -tile 3x1 image1.ppm image2.ppm image3.ppm concatenated.miff

3. 显示图像

gm display 'vid:*.jpg'

4. 格式转换

gm convert a.bmp a.jpg

gm convert a.bmp a.pdf(转换为pdf)

5. 调整图像dpi和大小

gm convert -density 288 -geometry 25% image.gif image.gif

(缩小为原先的1/4,并且dpi为288)

gm convert -resize 640x480 image.gif image.gif

(转换为640x480的图像)

6. 在图像上添加文字

gm convert -font Arial -fill blue -pointsize 18 -draw "text 10,10 'your text here'" test.tif test.png

7. 从gif文件中抽取一帧

gm convert "Image.gif[0]" first.gif

8. 建立gif图像

gm convert -delay 20 frame*.gif animation.gif

gm convert -loop 50 frame*.gif animation.gif

(让动画循环50次)

gm convert -delay 20 frame1.gif -delay 10 frame2.gif -delay 5 frame3.gif animation.gif

(对每一帧手动指定延时)

9. 截屏

gm import a.jpg

用鼠标点击所要截取的窗口,或者选择截屏区域,保存为a.jpg

gm import -frame a.jpg

保留窗口的边框

Apache22中配置虚拟主机(Apache VirtualHost)

Apache VirtualHost的作用就是可以让一个apache为多个域名服务,相当于一个服务器挂了N多个网站,举个例子:

我的apache服务器,ip为x.x.x.x,我有两个域名www.tootoogo.org和lp.tootoogo.org,设置这两个域名都指向x.x.x.x,在apache服务器上设置virtual host后,apache服务器可以实现同时为这两个域名服务,使得这两个域名分别指向不同的网页,于是我的一个服务器上就同时有了两个网站。

Apache VirtualHost配置方法:
在httpd.conf文件末尾添加以下内容

NameVirtualHost *:80

<VirtualHost *:80>
ServerAlias www.tootoogo.org  #貌似这一行没必要
DirectoryIndex index.html index.php
DocumentRoot "/var/www/data1/“
ServerName www.tootoogo.org
ErrorLog "log/tootoogo-error_log"

CustomLog "logs/tootoogo.access"

</VirtualHost>

<VirtualHost *:80>
DirectoryIndex index.html index.php
DocumentRoot /var/www/data2/

ServerName lp.tootoogo.org

ErrorLog "log/lp.tootoogo-error_log"

CustomLog "logs/lp.tootoogo.access"

</VirtualHost>

这样就可以使用两个域名解析到同一IP上却得到不同页面。

如果要禁止用户直接用IP进行访问,只要在
NameVirtualHost *:80
这句之后插入以下内容:

<VirtualHost *:80>
ServerName YourIpAddress
<Location />
Order Allow,Deny
Deny from all
</Location>
</VirtualHost>

备注:

修改httpd.conf中的
<Directory "/usr/local/www/apache22/data">

<Directory "/usr/local/www/apache22/">
那么就可以
使用下面的目录分别放置这两个域名对应的网页了
DocumentRoot /usr/local/www/apache22/data1
DocumentRoot /usr/local/www/apache22/data1

////////////////题外话////////////

如果需要监听其他端口号,可以加入

Listen yourIP:port,例如Listen 192.168.1.1:8081,那么对应的

NameVIrtualHost *:8081<VirtualHost *:8081>

ServerName www.tootoogo.org:8081

//////////////////////////////////

关于Robots.txt

Rboxts.txt一般放置在网站的跟目录下,例如:www.tootoogo.org/Rboxts.txt,用来给网络搜索引擎(爬虫)进行提示,告诉他们本网站哪些网页你可以爬,哪些不许动,但是,他不能作为防火墙使用,只有极少数的善良爬虫会遵守Rboxts.txt的规则的。

1 允许爬虫爬任何网页

User-agent:*

Crawl-delay:5

Allow:/

2 拒绝爬虫爬任何网页

User-agent:*

Disallow:/

3 拒绝特定的爬虫(如google)

User-agent:Goolebot-Image

Disallow:/

4 禁止部分网页或目录

User-agent:*

Disallow:/cgi-bin/

Disallow:/private_dir/

Disallow:/secret/large_page.html

Allow:/

一个用来统计分析Apache, Lighttpd, tHttpd日志的脚本

#!/usr/bin/perl
#
#######################################################
###  Calomel.org calomel_web_report.pl  BEGIN
#######################################################
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#转自https://calomel.org/
#记得把my $logdir = '/var/log/web_server';和$logdir = '/var/log/lighttpd'替换成你自己的日志文件位置
#且只支持标准默认的log文件
use Time::Local;
my $logdir = '/var/log/web_server';

opendir D,$logdir or die "Could not open $logdir ($!)";
@logfiles = sort grep /^access.log/, readdir D;
closedir D;

# Just use the 6 most recently archived log files.
shift @logfiles while @logfiles > 6;

my (%host, %url, %status, %urlsperhost);
my ($mintime,$maxtime) = (10_000_000_000, 0);
my %mon = qw/Jan 0 Feb 1 Mar 2 Apr 3 May  4 Jun  5
             Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11/;

foreach my $f (@logfiles,'access.log'){
  $logdir = '/var/log/lighttpd' if $f eq 'access.log';
  open F,"$logdir/$f" or die "Could not open $logdir/$f ($!)";
  while(<F>){
    my ($host, $ident_user, $auth_user, $day,$mon,$year, $hour,$min,$sec,
    $time_zone, $method, $url, $protocol, $status,
    $bytes, $referer, $agent) =
    /                 # regexp begins
    ^               # beginning-of-string anchor
    (\S+)           # assigned to $host
    \               # literal space
    (\S+)           # assigned to $ident_user
    \               # literal space
    (\S+)           # assigned to $auth_user
    \               # literal space
    

              # literal left bracket
    (\d\d)          # assigned to $day
    \/              # literal solidus
    ([A-Z][a-z]{2}) # assigned to $mon
    \/              # literal solidus
    (\d{4})         # assigned to $year
    :               # literal colon
    (\d\d)          # assigned to $hour
    :               # literal colon
    (\d\d)          # assigned to $min
    :               # literal colon
    (\d\d)          # assigned to $sec
    \               # literal space
    ([^

]+) # assigned to $time_zone $$\ " # literal string '] "' (\S+) # assigned to $method \ # literal space (.+?) # assigned to $url \ # literal space (\S+) # assigned to $protocol "\ # literal string '" ' (\S+) # assigned to $status \ # literal space (\S+) # assigned to $bytes \ # literal space "([^"]+)" # assigned to $referer \ # literal space "([^"]+)" # assigned to $agent $ # end-of-string anchor /x # regexp ends, with x modifier or next; $host eq '::1' and next; # Ignore Apache generated requests from localhost. $bytes =~ /^\d+$/ or $bytes = 0; $host{$host}++; $bytesperhost{$host} += $bytes; $url{$url}++; $status_class = int($status/100) . '00'; $status{$status_class}++; $urlsperhost{"$host $url"}++; # Parse the $time_zone variable. my $tz = 0; my ($tzs,$tzh,$tzm) = $time_zone =~ /([\-+ ])(\d\d)(\d\d)/; if(defined $tzs){ $tzs = $tzs eq '-' ? 1 : -1; $tz = $tzs * (3600*$tzh + 60*$tzm); } my $time = timegm($sec,$min,$hour,$day,$mon{$mon},$year-1900) + $tz; $mintime = $time if $time < $mintime; $maxtime = $time if $time > $maxtime; } close F; } my $start = localtime $mintime; my $end = localtime $maxtime; print "Analysis of log records between:\n$start and\n$end\n\n"; my %dns; my @toprequestors = (sort { $host{$b} <=> $host{$a} } keys %host)[0..9]; print "Top 10 requesters:\n"; foreach my $host (@toprequestors){ my $name = dns($host); printf " %-15s %12s requests$name\n",$host,add_commas($host{$host}); } print "\n"; my @topvolume = (sort { $bytesperhost{$b} <=> $bytesperhost{$a} } keys %bytesperhost)[0..9]; print "Top 10 by volume downloaded:\n"; foreach my $host (@topvolume){ my $name = dns($host); printf " %-15s %16s bytes$name\n",$host,add_commas($bytesperhost{$host}); } print "\n"; my @topurls = (sort { $url{$b} <=> $url{$a} } keys %url)[0..9]; print "Top 10 URLs requested:\n"; foreach my $url (@topurls){ printf " %12s $url\n",add_commas($url{$url}); } print "\n"; my @topurlsperhost = (sort { $urlsperhost{$b} <=> $urlsperhost{$a} } keys %urlsperhost)[0..9]; print "Top 10 URLs per host:\n"; foreach my $hosturl (@topurlsperhost){ my ($host,$url) = split " ",$hosturl; my $name = dns($host); printf " %4d %-15s $url$name\n",$urlsperhost{$hosturl},$host; } print "\n"; print "Number of requests per status class:\n"; foreach my $class (sort {$a <=> $b} keys %status){ printf "%4d %16s\n",$class,add_commas($status{$class}); } sub dns{ my $ip = shift; return $dns{$ip} if defined $dns{$ip} && $dns{$ip}; my $lookup = `/usr/sbin/host $ip 2>/dev/null`; my $name; if($lookup =~ /NXDOMAIN/ or $lookup =~ /SERVFAIL/ or $lookup =~ /timed out/ ){ $name = ''; } else{ $name = (split ' ',$lookup)[-1]; $name =~ s/\.$//; $name = " ($name)"; } $dns{$ip} = $name if $name; $name; } sub add_commas{ # Add commas to a number string (e.g. 1357924683 => 1,357,924,683) my $num = reverse shift; $num =~ s/(...)/$1,/g; chop $num if $num =~ /,$/; $num = reverse $num; } ####################################################### ### Calomel.org calomel_web_report.pl END #######################################################

NGINX的配置文件

#转自https://calomel.org/
#######################################################
### Calomel.org /etc/nginx.conf BEGIN
#######################################################
#
pid /var/run/nginx.pid;
user nginx nginx;
worker_processes 4;

events {
worker_connections 1024;
}

http {
## MIME types
types {
application/xml xml;
image/gif gif;
image/jpeg jpg;
image/png png;
image/bmp bmp;
image/x-icon ico;
text/css css;
text/html html;
text/plain bob;
text/plain txt;
}
default_type application/octet-stream;

## Size Limits
client_body_buffer_size 8k;
client_header_buffer_size 1k;
client_max_body_size 1k;
large_client_header_buffers 1 1k;

## Timeouts
client_body_timeout 5;
client_header_timeout 5;
keepalive_timeout 5 5;
send_timeout 5;

## General Options
ignore_invalid_headers on;
limit_zone gulag $binary_remote_addr 1m;
recursive_error_pages on;
sendfile on;
server_name_in_redirect off;
server_tokens off;

## TCP options
tcp_nodelay on;
tcp_nopush on;

## Compression
gzip on;
gzip_static on;
gzip_buffers 16 8k;
gzip_comp_level 9;
gzip_http_version 1.0;
gzip_min_length 0;
gzip_types text/plain text/html text/css image/x-icon image/bmp;
gzip_vary on;

## Log Format
log_format main '$remote_addr $host $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"';

## Deny access to any host other than (www.)mydomain.com
server {
server_name _; #default
return 444;
}

## Server (www.)mydomain.com
server {
add_header Cache-Control public;
access_log /var/log/nginx/access.log main buffer=32k;
error_log /var/log/nginx/error.log info;
expires 31d;
limit_conn gulag 5;
listen 127.0.0.1:8080 rcvbuf=64k backlog=128;
root /htdocs;
server_name mydomain.com www.mydomain;

## Only allow GET and HEAD request methods
if ($request_method !~ ^(GET|HEAD)$ ) {
return 444;
}

## Deny illegal Host headers
if ($host !~* ^(mydomain.com|www.mydomain.com)$ ) {
return 444;
}

## Deny certain User-Agents (case insensitive)
## The ~* makes it case insensitive as opposed to just a ~
if ($http_user_agent ~* (Baiduspider|Jullo) ) {
return 444;
}

## Deny certain Referers (case insensitive)
## The ~* makes it case insensitive as opposed to just a ~
if ($http_referer ~* (babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo) ) {
return 444;
}

## Redirect from www to non-www
if ($host = 'www.mydomain.com' ) {
rewrite ^/(.*)$ http://mydomain.com/$1 permanent;
}

## Stop Image and Document Hijacking
location ~* (\.jpg|\.png|\.css)$ {
if ($http_referer !~ ^(http://mydomain.com) ) {
return 444;
}
}

## Restricted Access directory
location ^~ /secure/ {
allow 127.0.0.1/32;
allow 10.10.10.0/24;
deny all;
auth_basic "RESTRICTED ACCESS";
auth_basic_user_file /var/www/htdocs/secure/access_list;
}

## Only allow these full URI paths relative to document root. If you only want
## to reference the filename use $request_filename instead of $request_uri
location / {
if ($request_uri ~* (^\/|\.html|\.jpg|\.org|\.png|\.css|favicon\.ico|robots\.txt)$ ) {
break;
}
return 444;
}

## Serve an empty 1x1 gif _OR_ an error 204 (No Content) for favicon.ico
location = /favicon.ico {
#empty_gif;
return 204;
}

## System Maintenance (Service Unavailable)
if (-f $document_root/system_maintenance.html ) {
error_page 503 /system_maintenance.html;
return 503;
}

## All other errors get the generic error page
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 495 496 497
500 501 502 503 504 505 506 507 /error_page.html;
location /error_page.html {
internal;
}
}
}
#
#######################################################
### Calomel.org /etc/nginx.conf END
#######################################################

第 4 页,共 6 页« 最新...23456