summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.Xresources13
-rw-r--r--.backupignore44
-rw-r--r--.bashrc22
-rw-r--r--.config/i3/config7
-rw-r--r--.fvwm2rc340
-rw-r--r--.i3status.conf2
-rw-r--r--.otp_accounts.json.gpg49
-rw-r--r--.profile10
-rw-r--r--.vim/plugin/cscope_maps.vim167
-rw-r--r--.vimrc2
-rw-r--r--.xinitrc30
-rwxr-xr-x.xsession24
-rwxr-xr-xbin/byo4
-rwxr-xr-xbin/gauth7
-rwxr-xr-xbin/hdmi8
-rwxr-xr-xbin/vm431
-rwxr-xr-xbin/xt1
17 files changed, 860 insertions, 301 deletions
diff --git a/.Xresources b/.Xresources
index 28b8436..b3589ed 100644
--- a/.Xresources
+++ b/.Xresources
@@ -7,9 +7,10 @@ URxvt.colorBD: blue3
URxvt.colorUL: magenta3
URxvt.cursorColor: red
! URxvt.color12: rgb:5c/5c/ff
-!URxvt.font: xft:Mono:size=12
-!URxvt.letterSpace: -1
Urxvt.font: 6x13
+!URxvt.font: xft:Mono:size=12
+!URxvt.font: xft:Mono:size=10
+URxvt.letterSpace: -1
URxvt.perl-ext-common: font-size
URxvt.keysym.C-Prior: font-size:increase
URxvt.keysym.C-Next: font-size:decrease
@@ -18,8 +19,10 @@ URxvt.keysym.C-Next: font-size:decrease
xterm*termName: xterm-256color
xterm*VT100.Translations: #override \
- Meta <Key> minus: smaller-vt-font() \n\
- Meta <Key> equal: larger-vt-font() \n
+ Ctrl <Key> Next: smaller-vt-font() \n\
+ Ctrl <Key> Prior: larger-vt-font() \n
+! Meta <Key> minus: smaller-vt-font() \n\
+! Meta <Key> equal: larger-vt-font() \n
xterm*cursorColor: red
!xterm*visualBell: true
!xterm*geometry: 100x32
@@ -32,6 +35,8 @@ xterm*decTerminalID: vt340
xterm*allowWindowOps : False
xterm*disallowedWindowOps : 1,2,3,4,5,6,7,8,9,11,13,18,19,20,21,GetSelection,SetSelection,SetWinLines,SetXprop
+! Colors optimized for a light background
+!
! Black + DarkGrey
*color0: #000000
*color8: #555753
diff --git a/.backupignore b/.backupignore
index 579b72d..bffc095 100644
--- a/.backupignore
+++ b/.backupignore
@@ -1,37 +1,9 @@
-.Trash/
-*[Cc]ache*/
-.bundle/
-.*[Cc]ache*/
-.cargo/
-.cpan*
-.gem/
-.ipfs/
-.npm/
-.vm*/
-go/pkg
-*.lock
-*.socket
-*.db-wal
-*.db-shm
-*.old
-*.log
+.*[Cc]ache/
+*[Cc]ache/
+CacheStorage/
+go/pkg/
+gopath/pkg/
+sigfox/vm/
+nvlib/
+dvlib/
*.o
-*- Google Drive
-build/*/
-httpstorages.*
-SiriAnalytics.db
-Application Support/Knowledge/
-IdentityServices/
-Library/Biome/
-Library/Calendars/
-Library/Saved Application State/
-Containers/com.adguard.*
-Containers/com.apple.Safari/
-Containers/com.ranchero.NetNewsWire-Evergreen/
-CoreSpotlight/
-Google/DriveFS/
-GoogleSoftwareUpdate/
-Group Containers/group.com.apple.secure-control-center-preferences/
-Safari/Databases/
-Safari/LocalStorage/
-Safari/Template Icons/
diff --git a/.bashrc b/.bashrc
index c977a96..00fdd0a 100644
--- a/.bashrc
+++ b/.bashrc
@@ -32,23 +32,22 @@ fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; }
#export LESS_TERMCAP_us=$(tput setaf 5) # underline (magenta)
#export LESS_TERMCAP_ue=$'\E[0m' # end underline
-# Less: use a 4-space tabulation
+export BACKUP=bip:/home/backup/marc@$(hostname -s)
export LESS=Rx4
# gnuplot display in terminal
export GNUTERM='sixelgd enhanced truecolor font "arial,9"'
-export BACKUP=bip:/home/backup/marc@m1
-
# Stopwatch
alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
-#export TERMINAL=xt
-#alias cl='cf xft:Mono:size=12'
-#alias cp='cp --reflink'
-#alias ls='ls --color=auto -v'
-alias ls='ls -GF'
-alias ll='ls -AlGFhv'
+export TERMINAL=xt
+
+alias cl='cf xft:Mono:size=12'
+alias cp='cp --reflink'
+alias ls='ls --color=auto -v'
+alias ll='ls -AlFhv'
+alias more='less'
alias vi='vim'
alias view='vim -R'
alias ldd='otool -L'
@@ -66,6 +65,8 @@ alias god='p go doc'
alias gol='GO111MODULE=off go'
alias gtr='go test -v -run'
alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench'
+alias kd='sudo cat /sys/kernel/debug/tracing/trace_pipe'
+
alias rvi='sudo vim'
alias rxt='sudo xt'
alias rxvi='sudo xvi'
@@ -145,4 +146,5 @@ meteo() {
# Display git status in prompt
. ~/.bash-powerline.sh
-export GITHUB_TOKEN=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
+eval "$(direnv hook bash)"
+#export GITHUB_TOKEN=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
diff --git a/.config/i3/config b/.config/i3/config
index 48c461c..182f119 100644
--- a/.config/i3/config
+++ b/.config/i3/config
@@ -68,6 +68,7 @@ for_window [class="Display"] floating enable
for_window [class="Feedreader"] floating enable
for_window [class="feh"] floating enable
for_window [class="firefox"] floating enable
+for_window [class="fluent-reader"] floating enable
for_window [class="Geeqie"] floating enable
for_window [class="Gpicview"] floating enable
for_window [class="Ghb"] floating enable
@@ -76,17 +77,21 @@ for_window [class="gnuplot_qt"] floating enable
for_window [instance="gxditview"] floating enable
for_window [class="Keybase"] floating enable
for_window [class="libreoffice"] floating enable
+for_window [class="Liferea"] floating enable
for_window [class="llpp"] floating enable
for_window [class="MuPDF"] floating enable
+for_window [class="Org.gnome.Software"] floating enable
for_window [class="Pavucontrol"] floating enable
-for_window [class="Slack"] floating enable
+for_window [title="QEMU"] floating enable
for_window [class="Signal"] floating enable
+for_window [class="Slack"] floating enable
for_window [class="Spotify"] floating enable
for_window [class="Thunderbird"] floating enable
for_window [class="vlc"] floating enable
for_window [instance="wish"] floating enable
for_window [class="wpa_gui"] floating enable
for_window [class="XVroot"] floating enable
+#for_window [class="XTerm"] floating enable
for_window [class="zoom"] floating enable
bindsym button3 floating toggle
diff --git a/.fvwm2rc b/.fvwm2rc
new file mode 100644
index 0000000..fac2b23
--- /dev/null
+++ b/.fvwm2rc
@@ -0,0 +1,340 @@
+HilightColor black IndianRed
+WindowFont fixed
+IconFont fixed
+MenuStyle black grey76 grey30 fixed fvwm
+IgnoreModifiers 2
+
+#Style "*" SloppyFocus
+Style "*" MouseFocusClickRaises
+Style "*" ForeColor black
+Style "*" BackColor SteelBlue
+Style "*" IconBox 800x64+0-0
+Style "*" MWMFunctions, MWMButtons, MWMBorder, MWMDecor, DecorateTransient, StickyIcon
+Style "*" RandomPlacement
+
+OpaqueMoveSize 0
+#EdgeScroll 100 100
+#EdgeScroll 100000 100000
+EdgeScroll 0 0
+EdgeResistance 100000 100000
+#style "*" EdgeMoveResistance 100000 100
+
+DeskTopSize 2x2
+
+#ImagePath /usr/X11R6/include/X11/pixmaps/
+#ImagePath /usr/share/pixmaps/
+
+Style "*" BorderWidth 4, HandleWidth 4
+Style "Fvwm*" NoTitle, Sticky, WindowListSkip
+Style "*Pager" NoHandles, BorderWidth 0, WindowListSkip, CirculateSkip
+Style "FvwmBanner" StaysOnTop
+Style "FvwmButtons" NoTitle, NoHandles, Sticky, WindowListSkip,BorderWidth 4
+Style "*lock" NoTitle, NoHandles, WindowListSkip
+Style "gkrellm" NoTitle, Sticky, WindowListSkip, CirculateSkip
+#Style "*unknown*" NoTitle, BorderWidth 0, NoHandles, WindowListSkip
+
+#Style "rxvt" Icon Monitor.xpm
+#Style "xterm" Icon Monitor.xpm
+#Style "uxterm" Icon Monitor.xpm
+
+#========================================================================#
+# Stuff to do at start-up
+#
+
+AddToFunc "StartFunction"
++ "I" Module FvwmPager 0 0
++ "I" Exec dunst
+#+ "I" Exec xsetroot -solid rgb:3/4/5
+#+ "I" Exec setxkbmap fr
+#+ "I" Exec synclient VertScrollDelta=-114
+
+#========================================================================#
+# Now define some handy complex functions
+#
+AddToFunc "Move-or-Raise" "M" Move
++ "M" Raise
++ "C" Raise
++ "D" Maximize 100 100
+
+AddToFunc "Move-or-Lower" "M" Move
++ "M" Lower
++ "C" Lower
++ "D" RaiseLower
+
+AddToFunc "Move-or-Iconify" "M" Move
++ "D" Iconify
+
+AddToFunc "Resize-or-Raise" "M" Resize
++ "M" Raise
++ "C" Raise
++ "D" RaiseLower
+
+AddToFunc "Focus-and-Raise" I Focus
++ I Iconify false
++ I Raise
++ I WarpToWindow 50 8p
+
+#========================================================================#
+DestroyMenu "Quit-Verify"
+AddToMenu "Quit-Verify"
+#+ "&Lock screen" Exec exec vlock -an
++ "&Fvwm restart" Restart
+#+ "&Lock screen" Exec exec slock sudo sh -c "echo mem > /sys/power/state"
++ "&Quit X11" Quit
++ "&Suspend" Exec exec slock sudo sh -c "echo mem > /sys/power/state"
+#+ "&Suspend" Exec exec suspend
++ "&Reboot" Exec exec sudo /sbin/reboot
++ "&Power off" Exec exec sudo /sbin/poweroff
+
+DestroyMenu "Module-Popup"
+AddToMenu "Module-Popup"
++ "Debug" Module FvwmDebug
++ "Identify" Module FvwmIdent
++ "Window List" Module FvwmWinList
+
+DestroyMenu "Desktop-Apps"
+AddToMenu "Desktop-Apps"
++ "&Brave" Exec exec brave
++ "&Chromium" Exec exec chromium
++ "&Discord" Exec exec discord
++ "&Firefox" Exec exec firefox
++ "&LibreOffice" Exec exec libreoffice
++ "&Keybase" Exec exec keybase-gui
++ "S&ignal" Exec exec signal-desktop
++ "&Slack" Exec exec slack
++ "&Zoom" Exec exec zoom
+
+DestroyMenu "Settings"
+AddToMenu "Settings"
++ "&Display" Exec exec arandr
++ "&Keyboard" Exec exec setxkbmap fr
++ "&Power" Exec exec sudo xt -e powertop
++ "&Sound" Exec exec pavucontrol
++ "&Wifi" Exec exec sudo wpa_gui -i wlo1
+
+DestroyMenu "Multimedia"
+AddToMenu "Multimedia"
++ "&Geeqie" Exec exec geeqie
++ "&Molotov" Exec exec molotov
++ "&Spotify" Exec exec spotify
++ "&Vlc" Exec exec vlc
+
+DestroyMenu "Utilities"
+AddToMenu "Utilities"
+#+ "&Xterm" Exec exec uxterm -sl 500 -j -ls -cr red
+#+ "&Top" Exec exec uxterm -T Top -n Top -e top
+#+ "&Xterm" Exec exec urxvtc +sb -sl 500 -j -ls -cr red
++ "&Xterm" Exec exec xt
++ "&Black Xterm" Exec exec bxt
++ "&Top" Exec exec xt -T Top -n Top -e /bin/top
++ "&Web" Exec exec chromium --disk-cache-dir=/tmp/chromium-cache
+#+ "&Web" Exec exec brave
+#+ "&Firefox" Exec exec firefox
+#+ "&Chromium" Exec exec chromium --disk-cache-dir=/tmp/chromium-cache
++ "&Mail" Exec exec thunderbird
+#+ "xclipboard" Exec exec xclipboard
+#+ "" Nop
++ "" Nop
++ "&System" Popup Settings
++ "&Desktop" Popup Desktop-Apps
++ "M&ultimedia" Popup Multimedia
++ "ssh bip" Exec exec uxterm -j -sl 500 -cr red -e mosh bip
+#+ "ssh dev.ugrid.net" Exec exec uxterm -j -sl 500 -cr red -e ssh dev.ugrid.net
++ "" Nop
++ "&Quit" Popup Quit-Verify
+
+# Define the most common window operations
+DestroyMenu "Window Ops"
+AddToMenu "Window Ops"
++ "&Move Alt+F5" Function Move-or-Raise
++ "&Resize Alt+F6" Function Resize-or-Raise
++ "R&aise" Raise
++ "&Lower" Lower
++ "(De)Iconify" Iconify
++ "(Un)Stick" Stick
++ "(Un)Maximize Alt+F12" Function maximize_func
++ "" Nop
++ "&Kill" Destroy
++ "&Close" Delete
++ "" Nop
++ "Switch to..." WindowList
++ "Refresh Screen" Refresh
+
+#
+# A trimmed down version of "Window Ops", good for binding to decorations
+#
+AddToMenu "Window-Ops2" "&Move Alt+F5" Move-or-Raise
++ "&Size Alt+F6" Resize-or-Raise
++ "Mi&nimize Alt+F4" Iconify 1
++ "&Horizontal Max Alt+F10" Maximize 100 0
++ "&Vertical Max Alt+F11" Maximize 0 100
++ "Ma&ximize Alt+F12" Maximize 100 100
++ "" Nop
++ "&Kill" Destroy
++ "&Close" Delete
+
+#========================================================================#
+#
+# One more complex function - couldn't be defined earlier because it used
+# pop-up menus
+#
+# This creates the "system" menu for the title-bar window-ops
+# pop-up
+#
+AddToFunc "window_ops_func" "C" PopUp Window-Ops2
++ "M" PopUp Window-Ops2
++ "D" Delete
+
+#========================================================================#
+#
+# Mouse bindings
+#
+
+# First, for the mouse in the root window
+# Button 1 gives the Utilities menu
+# Button 2 gives the Window Ops menu
+# Button 3 gives the WindowList (like TwmWindows)
+# I use the AnyModifier (A) option for the modifier field, so you can hold down
+# any shift-control-whatever combination you want!
+
+# Button Context Modifi Function
+Mouse 1 R A Menu "Utilities" Nop
+Mouse 2 R A Menu "Window Ops" Nop
+Mouse 3 R A WindowList
+
+# Now the title bar buttons
+# Any button in the left title-bar button gives the window ops menu
+# Any button in the first right title-bar button Iconifies the window
+# Any button in the second title-bar button full-maximizes
+# Note the use of "Mouse 0" for AnyButton.
+
+# Button Context Modif Function
+Mouse 0 1 A Function "window_ops_func"
+Mouse 0 2 A Maximize 100 100
+Mouse 0 4 A Iconify
+
+# Now the rest of the frame
+# Here I invoke my complex functions for Move-or-lower, Move-or-raise,
+# and Resize-or-Raise.
+#
+# Button 1 in the corner/sides pieces, with any modifiers, gives resize or raise
+Mouse 1 FS A Function "Resize-or-Raise"
+# Button 1 in the title, or icon, w/ any modifiers, gives move or raise
+Mouse 1 T A Function "Move-or-Raise"
+
+# Button 1 in an icons gives move for a drag, de-iconify for a double-click,
+# nothing for a single click
+# Button 2 in an icon, w/ any modifiers, gives de-iconify
+Mouse 1 I A Function "Move-or-Iconify"
+Mouse 2 I A Iconify
+
+# Button 2 in the corners, sides, or title-bar gives the window ops menu
+Mouse 2 FST A Function "window_ops_func"
+
+# Button 3 anywhere in the decoration (except the title-bar buttons)
+# does a raise-lower
+Mouse 3 TSIF A RaiseLower
+
+# Button 3 in the window, with the Modifier-1 key (usually alt or diamond)
+# gives Raise-Lower. Used to use control here, but that interferes with xterm
+Mouse 3 W M RaiseLower
+
+#========================================================================#
+# Now some keyboard shortcuts.
+# Arrow Keys, wrap mode enabled
+# press arrow + control anywhere, and scroll by 1 page
+Key Left A C Scroll -100000 0
+Key Right A C Scroll +100000 +0
+Key Up A C Scroll +0 -100000
+Key Down A C Scroll +0 +100000
+
+#Key Left A C Scroll -100 0
+#Key Right A C Scroll +100 +0
+#Key Up A C Scroll +0 -100
+#Key Down A C Scroll +0 +100
+#
+# press arrow + meta key, and scroll by 1/10 of a page
+#Key Left A M Scroll -10 +0
+#Key Right A M Scroll +10 +0
+#Key Up A M Scroll +0 -10
+#Key Down A M Scroll +0 +10
+
+# press shift arrow + control anywhere, and move the pointer by 1% of a page
+Key Left A SC CursorMove -1 0
+Key Right A SC CursorMove +1 +0
+Key Up A SC CursorMove +0 -1
+Key Down A SC CursorMove +0 +1
+
+# press shift arrow + meta key, and move the pointer by 1/10 of a page
+Key Left A SM CursorMove -10 +0
+Key Right A SM CursorMove +10 +0
+Key Up A SM CursorMove +0 -10
+Key Down A SM CursorMove +0 +10
+
+# Keyboard accelerators
+Key Super_L A A Popup "Utilities"
+Key F1 A M Popup "Utilities"
+Key F2 A M Popup "Window Ops"
+Key F3 A M Module "WindowList" FvwmWinList
+Key F4 A M Iconify
+Key F5 A M Move
+Key F6 A M Resize
+Key F7 A M RaiseLower
+#Key F8 A M Exec exec xbacklight +10
+Key F9 A M Close
+Key F10 A M Maximize 100 0
+Key F11 A M Maximize 0 100
+Key F12 A M Maximize
+
+#Key XF86MonBrightnessDown A A Exec exec xbacklight -10
+#Key XF86MonBrightnessUp A A Exec exec xbacklight +10
+Key XF86AudioRaiseVolume A A Exec exec amixer set Master 5%+
+Key XF86AudioLowerVolume A A Exec exec amixer set Master 5%-
+Key XF86AudioMute A A Exec exec amixer set Master toggle
+
+#Page Up/Dapge Down keys are used to scroll by one desktop page
+# in any context, press page up/down + control
+# in root context, just pressing page up/down is OK
+#
+# I prefer the non-wrapping scroll. These are for example purposes only
+#Key Next A C Scroll 100000 0
+#Key Next R N Scroll 100000 0
+#Key Prior A C Scroll -100000 0
+#Key Prior R N Scroll -100000 0
+
+#Key Tab A M Prev Focus
+#Key Tab A MS Next Focus
+Key Tab A M Prev Focus-and-Raise
+Key Tab A MS Next Focus-and-Raise
+
+Key Escape A C WindowList
+
+
+#========================================================================#
+
+# Definitions used by the modules
+
+#------------------ Pager
+*FvwmPagerBack grey60
+*FvwmPagerFore black
+#*FvwmPagerFont -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
+*FvwmPagerFont fixed
+*FvwmPagerHilight #c3c3c3
+*FvwmPagerGeometry 80x60-1-1
+*FvwmPagerLabel 0 "swift"
+*FvwmPagerSmallFont 5x8
+
+#------------------ Identify
+*FvwmIdentBack #000080
+*FvwmIdentFore Yellow
+*FvwmIdentFont -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*
+
+#------------------ FvwmWinList
+*FvwmWinListBack #c3c3c3
+*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
diff --git a/.i3status.conf b/.i3status.conf
index 87656f8..7590d2b 100644
--- a/.i3status.conf
+++ b/.i3status.conf
@@ -93,8 +93,8 @@ memory {
cpu_temperature 0 {
format = "🌡%degrees °C"
#path = "/sys/class/hwmon/hwmon0/temp1_input"
- #path = "/sys/class/hwmon/hwmon7/temp1_input"
path = "/sys/class/hwmon/hwmon6/temp1_input"
+ #path = "/sys/class/hwmon/hwmon7/temp1_input"
}
tztime local {
diff --git a/.otp_accounts.json.gpg b/.otp_accounts.json.gpg
new file mode 100644
index 0000000..e99f48a
--- /dev/null
+++ b/.otp_accounts.json.gpg
@@ -0,0 +1,49 @@
+-----BEGIN PGP MESSAGE-----
+
+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
+0I6oD0UBjnXA
+=OCjq
+-----END PGP MESSAGE-----
diff --git a/.profile b/.profile
index fb64b2e..a8e1948 100644
--- a/.profile
+++ b/.profile
@@ -1,19 +1,11 @@
# ~/.profile
-PATH=~/bin:/opt/homebrew/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/opt/tcl-tk/bin:$PATH:~/go/bin:~/.cargo/bin
-
-if [ -z "$SSH_AUTH_SOCK" ] ; then
- eval `ssh-agent -s`
- ssh-add
-fi
+PATH=~/bin:$PATH:~/go/bin
[ "${SHELL##*/}" = bash ] && . ~/.bashrc
-# Last action: auto start X11 when logged on first console
#case $HOSTNAME in
#([sS]wift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startx ;;
#esac
-. "/opt/homebrew/etc/profile.d/bash_completion.sh"
-
tabs -4
diff --git a/.vim/plugin/cscope_maps.vim b/.vim/plugin/cscope_maps.vim
new file mode 100644
index 0000000..abcae71
--- /dev/null
+++ b/.vim/plugin/cscope_maps.vim
@@ -0,0 +1,167 @@
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" CSCOPE settings for vim
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+"
+" This file contains some boilerplate settings for vim's cscope interface,
+" plus some keyboard mappings that I've found useful.
+"
+" USAGE:
+" -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a
+" 'plugin' directory in some other directory that is in your
+" 'runtimepath'.
+"
+" -- vim 5: Stick this file somewhere and 'source cscope.vim' it from
+" your ~/.vimrc file (or cut and paste it into your .vimrc).
+"
+" NOTE:
+" These key maps use multiple keystrokes (2 or 3 keys). If you find that vim
+" keeps timing you out before you can complete them, try changing your timeout
+" settings, as explained below.
+"
+" Happy cscoping,
+"
+" Jason Duell jduell@alumni.princeton.edu 2002/3/7
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+
+" This tests to see if vim was configured with the '--enable-cscope' option
+" when it was compiled. If it wasn't, time to recompile vim...
+if has("cscope")
+
+ """"""""""""" Standard cscope/vim boilerplate
+
+ " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
+ set cscopetag
+
+ " check cscope for definition of a symbol before checking ctags: set to 1
+ " if you want the reverse search order.
+ set csto=0
+
+ " add any cscope database in current directory
+ if filereadable("cscope.out")
+ cs add cscope.out
+ " else add the database pointed to by environment variable
+ elseif $CSCOPE_DB != ""
+ cs add $CSCOPE_DB
+ endif
+
+ " show msg when any other cscope db added
+ set cscopeverbose
+
+
+ """"""""""""" My cscope/vim key mappings
+ "
+ " The following maps all invoke one of the following cscope search types:
+ "
+ " 's' symbol: find all references to the token under cursor
+ " 'g' global: find global definition(s) of the token under cursor
+ " 'c' calls: find all calls to the function name under cursor
+ " 't' text: find all instances of the text under cursor
+ " 'e' egrep: egrep search for the word under cursor
+ " 'f' file: open the filename under cursor
+ " 'i' includes: find files that include the filename under cursor
+ " 'd' called: find functions that function under cursor calls
+ "
+ " Below are three sets of the maps: one set that just jumps to your
+ " search result, one that splits the existing vim window horizontally and
+ " diplays your search result in the new window, and one that does the same
+ " thing, but does a vertical split instead (vim 6 only).
+ "
+ " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
+ " unlikely that you need their default mappings (CTRL-\'s default use is
+ " as part of CTRL-\ CTRL-N typemap, which basically just does the same
+ " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
+ " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
+ " of these maps to use other keys. One likely candidate is 'CTRL-_'
+ " (which also maps to CTRL-/, which is easier to type). By default it is
+ " used to switch between Hebrew and English keyboard mode.
+ "
+ " All of the maps involving the <cfile> macro use '^<cfile>$': this is so
+ " that searches over '#include <time.h>" return only references to
+ " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
+ " files that contain 'time.h' as part of their name).
+
+
+ " To do the first type of search, hit 'CTRL-\', followed by one of the
+ " cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope
+ " search will be displayed in the current window. You can use CTRL-T to
+ " go back to where you were before the search.
+ "
+
+ " MV: replace C-\ by C-,
+ nmap <C-,>s :cs find s <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-,>g :cs find g <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-,>c :cs find c <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-,>t :cs find t <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-,>e :cs find e <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-,>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
+ nmap <C-,>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
+ nmap <C-,>d :cs find d <C-R>=expand("<cword>")<CR><CR>
+
+
+ " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
+ " makes the vim window split horizontally, with search result displayed in
+ " the new window.
+ "
+ " (Note: earlier versions of vim may not have the :scs command, but it
+ " can be simulated roughly via:
+ " nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>
+
+ " MV: replace C-@ by C-;
+ nmap <C-;>s :scs find s <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-;>g :scs find g <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-;>c :scs find c <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-;>t :scs find t <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-;>e :scs find e <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-;>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
+ nmap <C-;>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
+ nmap <C-;>d :scs find d <C-R>=expand("<cword>")<CR><CR>
+
+
+ " Hitting CTRL-space *twice* before the search type does a vertical
+ " split instead of a horizontal one (vim 6 and up only)
+ "
+ " (Note: you may wish to put a 'set splitright' in your .vimrc
+ " if you prefer the new window on the right instead of the left
+
+ nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
+ nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
+ nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
+ nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
+
+
+ """"""""""""" key map timeouts
+ "
+ " By default Vim will only wait 1 second for each keystroke in a mapping.
+ " You may find that too short with the above typemaps. If so, you should
+ " either turn off mapping timeouts via 'notimeout'.
+ "
+ "set notimeout
+ "
+ " Or, you can keep timeouts, by uncommenting the timeoutlen line below,
+ " with your own personal favorite value (in milliseconds):
+ "
+ "set timeoutlen=4000
+ "
+ " Either way, since mapping timeout settings by default also set the
+ " timeouts for multicharacter 'keys codes' (like <F1>), you should also
+ " set ttimeout and ttimeoutlen: otherwise, you will experience strange
+ " delays as vim waits for a keystroke after you hit ESC (it will be
+ " waiting to see if the ESC is actually part of a key code like <F1>).
+ "
+ "set ttimeout
+ "
+ " personally, I find a tenth of a second to work well for key code
+ " timeouts. If you experience problems and have a slow terminal or network
+ " connection, set it higher. If you don't set ttimeoutlen, the value for
+ " timeoutlent (default: 1000 = 1 second, which is sluggish) is used.
+ "
+ "set ttimeoutlen=100
+
+endif
+
+
diff --git a/.vimrc b/.vimrc
index f002a86..8972385 100644
--- a/.vimrc
+++ b/.vimrc
@@ -8,7 +8,7 @@ filetype plugin on
filetype plugin indent on
let mapleader = ","
-set rtp+=/opt/homebrew/opt/fzf
+"set rtp+=/opt/homebrew/opt/fzf
let g:fzf_preview = 'cat {}'
" vimki plugin
diff --git a/.xinitrc b/.xinitrc
new file mode 100644
index 0000000..2ab853e
--- /dev/null
+++ b/.xinitrc
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /etc/X11/xinit/xinitrc.d/50-systemd-user.sh
+#eval $(ssh-agent)
+eval $(gnome-keyring-daemon --start)
+export SSH_AUTH_SOCK
+
+# start pulseaudio on crux only. Should be handled by systemd on arch
+#pulseaudio --start --exit-idle-time=-1 --log-target=syslog &
+
+# enable tapping and natural scrolling on touchpad
+# see xinput --list[-props] for ids
+xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Tapping Enabled' 1
+xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling Enabled' 1
+
+# Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards
+#setxkbmap fr
+#xk
+hdmi
+
+xrdb ~/.Xresources
+#xsetroot -solid rgb:3/4/5
+xsetroot -solid rgb:1/3/4
+#feh --bg-fill ~/Downloads/Alaska_Range.jpg
+#conky
+#slock
+
+# Start window manager
+#exec fvwm
+exec i3
diff --git a/.xsession b/.xsession
new file mode 100755
index 0000000..92f75e1
--- /dev/null
+++ b/.xsession
@@ -0,0 +1,24 @@
+#!/bin/sh
+# start pulseaudio on crux only. Should be handled by systemd on arch
+#pulseaudio --start --exit-idle-time=-1 --log-target=syslog &
+
+# enable tapping and natural scrolling on touchpad
+# see xinput --list[-props] for ids
+xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Tapping Enabled' 1
+xinput --set-prop 'SYNA7DAB:00 06CB:CD40 Touchpad' 'libinput Natural Scrolling Enabled' 1
+
+# Better use /etc/X11/xorg.conf.d/10-keyboard.conf to handle hot plugged keyboards
+#setxkbmap fr
+#xk
+hdmi
+
+xrdb ~/.Xresources
+#xsetroot -solid rgb:3/4/5
+xsetroot -solid rgb:1/3/4
+#feh --bg-fill ~/Downloads/Alaska_Range.jpg
+#conky
+#slock
+
+# Start window manager
+exec fvwm
+#exec i3
diff --git a/bin/byo b/bin/byo
index bc09fb8..93bb7f0 100755
--- a/bin/byo
+++ b/bin/byo
@@ -26,8 +26,8 @@ yoda_uuid='8c463221-6bb7-414e-9060-c9570bb3a6bb'
dest=/mnt/backup/$(hostname)
[ -b /dev/mapper/yoda ] && noclose=1 || cryptsetup open "$dev" yoda
findmnt /dev/mapper/yoda /mnt >/dev/null && noumount=1 || mount /dev/mapper/yoda /mnt
-time backup -v -d "$dest"
-[ ! "$optC" ] || backup -v -d "$dest" clean
+time backup -v "$dest"
+# [ ! "$optC" ] || backup -v -d "$dest" clean
[ ! "$optd" ] || time duperemove -drh --hashfile="$dest/.hashfile" "$dest"
df -h / "$dest"
ls -v "$dest"
diff --git a/bin/gauth b/bin/gauth
index 699cd84..b18f73d 100755
--- a/bin/gauth
+++ b/bin/gauth
@@ -1,10 +1,9 @@
#!/bin/sh
# Use backup from andOTP
-#gpg -qd ~/otp_accounts.json.gpg.pgp |
-#gpg -qd ~/.otp_accounts.json.gpg |
-cat ~/otp_accounts.json |
+# cat ~/.otp_accounts.json |
+gpg -qd ~/.otp_accounts.json.gpg 2>/dev/null |
jq -r '.[] | "\(.label) \(.secret)"' |
while read -r l s; do
echo "$l $(oathtool --totp -b "$s")"
-done
+done | column -t
diff --git a/bin/hdmi b/bin/hdmi
index d6f206a..e6e3094 100755
--- a/bin/hdmi
+++ b/bin/hdmi
@@ -2,8 +2,8 @@
# Toggle auxiliary HDMI screen on/off when connected/disconnected.
opt="--auto --left-of eDP1"
-#opt="--auto --right-of eDP-1"
-#opt="--auto --above eDP-1"
+#opt="--auto --right-of eDP1"
+#opt="--auto --above eDP1"
# Also add the following rule to /etc/udev/rules.d/hdmi.rules
# KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/marc/.Xauthority", RUN+="/home/marc/bin/hdmi"
@@ -11,5 +11,5 @@ opt="--auto --left-of eDP1"
# wait for the screen to settle
sleep 3
-xrandr | grep -q 'HDMI1 connected' || opt="--off"
-xrandr --output HDMI1 $opt
+xrandr | grep -q '^DP1 connected' || opt="--off"
+xrandr --output DP1 $opt
diff --git a/bin/vm b/bin/vm
index 6b03d0e..8b4da42 100755
--- a/bin/vm
+++ b/bin/vm
@@ -1,285 +1,258 @@
#!/bin/sh
-# vm is a command line tool to manage and operate virtual machines.
-
-vm_version='vm-0.1'
-
+# Manage virtual machines
+#
+# Prereq:
+# - curl
+# - cdrtools (isoinfo)
+# - expect
+# - qemu
+# - screen
+#
# TODO:
-# - DONE: fetch, build and install vftool in .vm/vftool
-# - DONE: setup a config file per VM
-# - DONE: creation of hdd image
-# - DONE: delete a VM
-# - DONE: import iso, kernel, initrd from existing vm
-# - when no vm is specified, apply command to last one
-# - script install from CDROM iso:
-# - patch alpine setup-disk
-# - setup system, including static IP address
-# - setup user account from host
-# - setup ssh from host
-# - time synchronization from host
+# - extract bzImage and initrd.gz with isoinfo
+# - ssh scripts to finish install (once ssh is ready)
+#
+# DONE:
+# - setup vde and networking
+# - setup ssh keys so it is possible to ssh in vm from host
#
-
unset CDPATH
export LC_ALL=C IFS='
'
-add() {
- usage 'add [Options] name' 'Add a new VM' && return
- while getopts :c:i:k:p:s: opt; do
- case $opt in
- [cikps]) eval "$opt=$OPTARG";;
- *) Opth=1 add "$1"; exit ;;
- esac
- done
- shift $((OPTIND - 1))
+version='vm-0.1'
- [ -d "$dir/$1" ] && die "vm $1 already exists in $dir/$1"
- init_alpine || die "could not init alpine iso"
- [ "$1" = 'alpine-iso' ] && return
- mkdir -p "$dir/$1" && cd "$dir/$1" || die "add $1 failed"
- hdd=${p-$1.raw}
- [ -f "$hdd" ] || dd if=/dev/zero of="$hdd" bs=1 count=0 seek="${s-32g}" 2>/dev/null
- echo "hdd=\"$hdd\"" > config
- [ "$c" ] && {
- [ -d "../$c" ] || die "invalid directory: $dir/$c"
- iso=$(getconf "$c" iso)
- cp "../$c/vmlinux" "../$c/initrd" .
- [ "$iso" ] && echo "iso=\"../$c/$iso\"" >> config
- cat <<- EOT >> config
- kernel=${k-vmlinux}
- initrd=initrd
- cpu=1
- ram=512
- arg="console=hvc0"
- EOT
- }
-}
+arch=$(uname -m)
+sys=$(uname -s)
+alpine_version='3.15.0'
+pubkey=$HOME/.ssh/id_rsa.pub
+dir="${VM_DIR:-$HOME/.vm}"
console() {
- usage 'console name' 'Attach a console to a VM' && return
- [ "$1" ] || die 'console: name is missing'
- cd "$dir/$1" || die "console $1 failed"
- [ -f vftool.pid ] || die "vm $1 is not active"
- screen -r "$1"
+ usage 'console name' 'Attach a console to a virtual machine' && return
+ [ "$1" ] || die "missing argument"
+ is_running "$1" && screen -r "vm!$1!"
}
-del() {
- usage 'del name' 'Delete a VM' && return
- case $1 in ''|*/*|.*) die "invalid VM name: $1" ;; esac
- [ -d "$dir/$1" ] || die "$dir/$1 not found"
- [ -f "$dir/$1/vftool.pid" ] && die "vm $1 is still active, stop it first"
- rm -rf "${dir:?}/$1"
+create() {
+ usage 'create [-s size] name' 'Create an alpinelinux disk image' && return
+ size=8g
+ while getopts :s: opt; do
+ case $opt in
+ s) size=$OPTARG ;;
+ *) Opth=2 create_alpine_image; return ;;
+ esac
+ done
+ shift $((OPTIND - 1))
+ [ -d "$dir/$1" ] && die "create failed: $dir/$1 already exists"
+ mkdir "$dir/$1"
+ cd "$dir/$1" || die "create failed: invalid directory $dir/$1"
+ qemu-img create "$1.raw" "$size" || die "create failed"
+ mac=$(new_macaddr)
+ ip=$(new_ip)
+ hdd="$1.raw"
+ echo "hdd=$hdd
+mac=$mac
+ip=$ip" >> config
+
+ # Before install do not use virtio, as devices may not recognized as bootable
+ # TODO: alternate way: extract kernel and initrd files and pass them directly to qemu
+ screen -S "vm!$1!" -d -m qemu-system-$arch -nographic \
+ -cdrom ../alpine-iso/alpine-virt-$alpine_version-$arch.iso \
+ -hdd "$hdd" -net nic,macaddr=$mac -net vde
+ setup_alpine "$1"
+ post_setup_alpine "$1"
}
die() { [ "$1" ] && echo "$0: $*" >&2; exit 1; }
-edit() {
- usage 'edit name' 'Edit a VM configuration' && return
- [ -f "$dir/$1/config" ] || die "$dir/$1/config not found"
- ${EDITOR-vi} "$dir/$1/config"
-}
-
-exp() {
- usage 'exp name' 'experiment on a VM' && return
- cd "$dir/$1" || die "invalid VM: $1"
- [ -f vftool.pid ] || die "vm $1 is not active"
-
- sleep 1 && screen -X stuff 'root
-'
- sleep 1 && screen -X stuff 'sed -i.bak "s/die..Bootloader/;; # die \"Bootloader/" /sbin/setup-disk
-'
- sleep 1 && screen -X stuff 'setup-alpine -e
-'
- sleep 1 && screen -X stuff 'none
-'
- sleep 1 && screen -X stuff "$1
-"
- sleep 1 && screen -X stuff 'eth0
-'
- sleep 1 && screen -X stuff '192.168.64.2
-'
- sleep 1 && screen -X stuff '255.255.255.0
-'
- sleep 1 && screen -X stuff '192.168.64.1
-'
- sleep 1 && screen -X stuff 'n
-'
- sleep 3 && screen -X stuff '
-'
- sleep 1 && screen -X stuff '192.168.64.1
-'
- sleep 1 && screen -X stuff 'Europe/Paris
-'
- sleep 5 && screen -X stuff 'none
-'
- sleep 1 && screen -X stuff 'chrony
-'
- sleep 5 && screen -X stuff '1
-'
- sleep 1 && screen -X stuff 'openssh
-'
- sleep 5 && screen -X stuff 'vda
-'
- sleep 3 && screen -X stuff 'sys
-'
- sleep 1 && screen -X stuff 'y
-'
- sleep 20 && screen -X stuff 'blkid /dev/vda3
-'
-}
-
-finalize() {
- tty=$(vftool_tty)
- printf 'root\nuname -a\n' >> "$tty"
-}
-
-getconf() { awk -F '=' -v k="$2" '$1 == k {print $2}' "$dir/$1/config"; }
-
help() {
usage 'help' 'Print this help text' && return
- printf '%s\n' "$vm_version\nManage virtual machines\nUsage: vm command [options] [args]"
+ printf "$version\n Manage virtual machines\n\nUsage: vm command [options] [args]\n"
Opth=1; for c in $Cmdlist; do $c; done
}
-info() {
- usage 'info name' 'Print informations on a VM' && return
- echo 'not implemented yet'
+init() {
+ mkdir -p "$dir"
}
-# CAUTION: be careful to preserve tabs in the following Makefile template string.
-
-alpine_makefile='# Generated by "vm". DO NOT EDIT.
-# Check https://alpinelinux.org/downloads for possible upgrades
-iso_url = https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.3-aarch64.iso
-iso = $(notdir $(iso_url))
-isoinfo ?= /opt/homebrew/bin/isoinfo
-
-all: initrd vmlinux config
+init_alpine_iso() {
+ usage init_alpine_iso '' && return
+ mkdir -p "$dir/alpine-iso"
+ iso_url="https://dl-cdn.alpinelinux.org/alpine/v${alpine_version%.*}/releases/$arch"
+ iso="alpine-virt-$alpine_version-$arch.iso"
+ cd "$dir/alpine-iso"
+ [ -f "$iso" ] || curl -LO "$iso_url/$iso" || rm -f "$iso"
+ echo "iso=$iso
+" > config
+ echo 10 > ../index
+}
-initrd: $(iso) $(isoinfo)
- isoinfo -i $(iso) -J -x /boot/initramfs-virt > $@
+is_running() { screen -ls "vm!$1!" >/dev/null 2>&1; }
-vmlinux: $(iso) $(isoinfo)
- isoinfo -i $(iso) -J -x /boot/vmlinuz-virt | gunzip > $@
+ls() {
+ usage 'ls' 'list virtual machines' && return
+ init && cd "$dir" || die "could not change dir to $dir"
+ for i in */; do
+ i=${i%/}
+ [ "$i" = '*' ] && continue
+ is_running "$i" && state=active || state=stopped
+ printf "%-20s %s\n" "$i" "$state"
+ done
+}
-config: $(iso)
- @echo "iso=$(iso)" >config
- @echo "initrd=initrd" >>config
- @echo "kernel=vmlinux" >>config
- @echo "cpu=1" >> config
- @echo "ram=512" >> config
- @echo "arg=\"console=hvc0\"" >> config
+new_ip() {
+ read index < $dir/index
+ index=$((index + 1))
+ echo "$index" > $dir/index
+ echo "10.0.2.$index/24"
+}
-$(iso):
- curl -LO $(iso_url) || { rm -f $@; false; }
+new_macaddr() { printf 'de:ad:be:ef:%02x:%02x\n' $((RANDOM % 256)) $((RANDOM % 256)); }
-$(isoinfo):
- brew install cdrtools
-'
+pidof() {
+ usage 'pidof name' 'print the PID of a virtual machine' && return
+ p=$(screen -ls "vm!$1!" | awk 'NR==2 {print substr($1, 1, index($1, ".")-1)}')
+ [ "$p" ] && pgrep -P $p
+}
-init_alpine() {
- mkdir -p "$dir/alpine-iso" && cd "$dir/alpine-iso" || die 'init alpine failed'
- [ -f 'Makefile' ] || printf '%s' "$alpine_makefile" > Makefile
- make -s all
+post_setup_alpine() {
+ start "$1"
+ read proto key id < "$pubkey"
+ # echo '
+ expect -c '
+ set timeout -1
+ spawn screen -x "vm!'$1'!"
+ expect {
+ " login: " { send "root\r"; exp_continue }
+ "Password: " { send "root\r"; exp_continue }
+ ":~# "
+ }
+ send "mkdir -pm 0700 .ssh\r"
+ expect ":~# "
+ send "echo '$proto' '$key' '$id' >.ssh/authorized_keys\r"
+ expect ":~# "
+ send "exit\r"
+ '
}
-init_vftool() {
- [ -x "$dir/vftool" ] && return
- cd '/tmp' &&
- git clone --depth=1 'https://github.com/evansm7/vftool' &&
- cd 'vftool' &&
- make &&
- cp 'build/vftool' "$dir/vftool"
- rm -rf '/tmp/vftool'
+# setup_alpine automates alpine installation from iso to image.
+# When done, base image system is ready, with storage and network up.
+# No user nor ssh access configured yet.
+# TODO: custom network (in case of no dhcp).
+setup_alpine() {
+ usage 'setup_alpine' && return
+ expect -c '
+ set timeout -1
+ spawn screen -x "vm!'$1'!"
+ expect {
+ "localhost login: " { send "root\r"; exp_continue }
+ "localhost:~# " { send "SWAP_SIZE=0 setup-alpine\r"; exp_continue }
+ "Select keyboard layout: " { send "\r"; exp_continue }
+ "Enter system hostname" { send "'$1'\r"; exp_continue }
+ "Which one do you want to initialize?" { send "\r"; exp_continue }
+ "Ip address for eth0?" { send "'$ip'\r"; exp_continue }
+ "Gateway?" { send "10.0.2.2\r"; exp_continue }
+ "manual network configuration?" { send "\r"; exp_continue }
+ "DNS domain name?" { send "lan\r"; exp_continue }
+ "DNS nameserver(s)?" { send "10.0.2.2 1.1.1.1\r"; exp_continue }
+ "New password:" { send "root\r"; exp_continue }
+ "Retype password:" { send "root\r"; exp_continue }
+ "Which timezone are you in?" { send "\r"; exp_continue }
+ "HTTP/FTP proxy URL?" { send "\r"; exp_continue }
+ "Enter mirror number " { send "\r"; exp_continue }
+ "Which SSH server?" { send "\r"; exp_continue }
+ "Which disk(s) would you like to use?" { send "sda\r"; exp_continue }
+ "How would you like to use it?" { send "sys\r"; exp_continue }
+ "Erase the above disk(s) and continue?" { send "y\r"; exp_continue }
+ "Installation is complete" { send "poweroff\r" }
+ }
+ interact
+ '
}
-log() {
- usage 'log name' 'print logs of a VM' && return
- [ "$1" ] || die "log failed: name missing"
- cd "$dir/$1" || die "log $1 failed"
- cat vftool.log.old vftool.log 2>/dev/null
+start_vde() {
+ usage start_vde && return
+ sudo sh <<- EOT
+ vde_switch -tap tap0 -sock /tmp/vde.ctl -daemon -mod 666
+ sleep 1
+ ip address add 10.0.2.2/24 dev tap0
+ ip link set tap0 up
+ echo 1 > /proc/sys/net/ipv4/ip_forward
+ iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o eth0 -j MASQUERADE
+ iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o wlan0 -j MASQUERADE
+ EOT
+ #slirpvde --dhcp --daemon
}
-ls() {
- usage 'ls' 'list VMs' && return
- [ -d "$dir" ] && cd "$dir" || return
- for i in */; do
- i=${i%/}
- [ "$i" = '*' ] && continue
- [ -f "$i/vftool.pid" ] && state=active || state=stopped
- printf "%-20s %s\n" "$i" "$state"
- done
+stop_vde() {
+ # killall slirpvde
+ sudo sh <<- EOT
+ iptables -t nat -D POSTROUTING -s 10.0.2.0/24 -o eth0 -j MASQUERADE
+ iptables -t nat -D POSTROUTING -s 10.0.2.0/24 -o wlan0 -j MASQUERADE
+ ip link set tap0 down
+ killall vde_switch
+ EOT
}
start() {
- usage 'start [-afs] name' 'Start a VM' && return
- while getopts :afs opt; do
+ usage 'start [-acd] name' 'start a virtual machine' && return
+ while getopts :acd opt; do
case $opt in
- (a) a=1 ;;
- (f) f=1 ;;
- (s) s=1 ;;
- (*) Opth=1 start "$1"; exit;;
+ a) opta=1 ;;
+ c) boot=c ;;
+ d) boot=d ;;
esac
done
- shift $((OPTIND - 1))
-
- [ "$1" ] || die "start failed: name missing"
- init_vftool
- cd "$dir/$1" || die "start $1 failed"
- [ -f vftool.pid ] && die "Error: process $(cat vftool.pid) is active or $PWD/vftool.pid should be removed"
- start_vm & sleep 2
- ! [ "$f" ] || finalize
- ! [ "$a" ] || vm console "$1"
- ! [ "$s" ] || exec ssh "$1"
+ shift $((OPTIND -1))
+ [ "$1" ] || die 'start failed: name missing'
+ cd "$dir/$1" || die "start failed: invalid directory $dir/$1"
+ is_running "$1" || start_qemu "$1"
+ [ "$opta" ] && console "$1"
}
-start_vm() (
- [ -f vftool.log ] && cat vftool.log >> vftool.log.old
- exec 1>vftool.log 2>&1
- . config || die "vm: could not source $PWD/config"
- trap 'rm -f vftool.pid' EXIT
-
- "$dir/vftool" \
- ${kernel+-k "$kernel"} \
- ${initrd+-i "$initrd"} \
- ${hda+-d "$hda"} \
- ${hdb+-d "$hdb"} \
- ${iso+-c "$iso"} \
- ${cpu+-p "$cpu"} \
- ${ram+-m "$ram"} \
- -a "${arg-console=hvc0}" \
- >>vftool.log 2>&1 & sleep 1
-
- echo "$!" >vftool.pid
- screen -S "${PWD##*/}" -d -m "$(vftool_tty)"
- wait
+start_qemu() (
+ opt='-nographic -cpu max'
+ [ "$sys" = Linux ] && opt="$opt -enable-kvm"
+ . ./config || die "could not source $PWD/config"
+ exec 1>>qemu.log 2>&1
+ date +%F_%T
+ set -x
+ screen -S "vm!$1!" -d -m qemu-system-$arch $opt \
+ ${smp+-smp $smp} \
+ ${ram+-m $ram} \
+ ${mac+-net nic,macaddr=$mac,model=virtio-net-pci} -net vde \
+ ${hdd+-drive file="$hdd",if=virtio,media=disk,format=raw} \
+ ${iso+-drive file="$iso",if=virtio,media=cdrom,format=raw} \
+ ${boot+-boot $boot}
)
stop() {
- usage 'stop name' 'Stop a VM' && return
- [ "$1" ] || die 'stop: name missing'
- cd "$dir/$1" || die "stop $1 failed"
- [ -f vftool.pid ] || die "stop: vm $1 is not active"
- kill "$(cat vftool.pid)" || rm -f vftool.pid
+ usage 'stop name' 'stop a virtual machine' && return
+ is_running "$1" && kill "$(pidof "$1")"
}
-usage() { [ "$Opth" ] && printf " %-34s %s\n" "$1" "$2"; }
+usage() {
+ case $Opth in
+ 1) printf " %-34s %s\n" "$1" "$2" ;;
+ 2) printf "$0 $1\n\t$2\n" ;;
+ *) return 1 ;;
+ esac
+}
version() {
usage 'version' 'Print version' && return
- echo "$vm_version"
+ echo "$version"
}
-vftool_tty() { grep -om 1 '\/dev\/tty.*' 'vftool.log'; }
-
-# Main starts here.
-dir="$HOME/.vm"
-Cmdlist='add console del edit exp info help ls log start stop version'
+Cmdlist='console create help init_alpine_iso ls pidof setup_alpine start start_vde stop version'
[ "$1" ] && C=$1 && shift 1 || { help; exit 1; }
-for c in $Cmdlist; do
- case $c in
- ("$C") cmd=$c; break ;;
- ("$C"*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c ;;
- esac
-done
+#for c in $Cmdlist; do
+# case $c in
+# ("$C") cmd=$c; break ;;
+# ("$C"*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c ;;
+# esac
+#done
+cmd=$C
[ "$cmd" ] || { help; exit 1; } && $cmd "$@"
diff --git a/bin/xt b/bin/xt
index 9395b3e..98f6ac6 100755
--- a/bin/xt
+++ b/bin/xt
@@ -2,4 +2,5 @@
#exec xterm -sl 500 -j -cr red "$@" &
exec xterm "$@" &
#cmd="urxvtc ${@:--T $HOSTNAME}"
+#cmd="urxvtc $@"
#eval "$cmd" || { [ $? = 2 ] && urxvtd -q -o -f && eval "$cmd"; }