Skip to content

Commit

Permalink
Fix issue 3151: missing .vimrc and overhauled 130_create_dotfiles.sh (#…
Browse files Browse the repository at this point in the history
…3154)

Create an empty
usr/share/rear/skel/default/root/.vimrc
to fix #3151
Furthermore in build/GNU/Linux/130_create_dotfiles.sh
dynamically generate .bash_history entries depending on
whether or not 'nano' and 'vi' are available, see
#3151 (comment)
and see #1306 regarding nano
and #1298 when vi is not available.
  • Loading branch information
jsmeix committed Feb 19, 2024
1 parent ca99d85 commit 700727b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
57 changes: 35 additions & 22 deletions usr/share/rear/build/GNU/Linux/130_create_dotfiles.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
# 200_create_dotfiles.sh
#
# 130_create_dotfiles.sh
#
# Create some . dot files for Relax-and-Recover
#
# This file is part of Relax-and-Recover, licensed under the GNU General
# Public License. Refer to the included COPYING for full text of license.

# create a simple bash history file,
# use this ruler to make sure the comments stay in a single line:
# the bash prompt is: 'RESCUE $HOSTNAME:~ #
# -----------------------------------------------------80-|
cat <<EOF > $ROOTFS_DIR/$ROOT_HOME_DIR/.bash_history
: # no more predefined ReaR entries in the bash history
systemctl start sshd.service # start SSH daemon
ip -4 addr # get IPv4 address
dhcpcd eth0 # start DHCP client
nano /var/lib/rear/layout/diskrestore.sh # disk restore
nano /var/lib/rear/layout/disklayout.conf # disk layout
vi /var/lib/rear/layout/diskrestore.sh # disk restore
vi /var/lib/rear/layout/disklayout.conf # disk layout
less /var/log/rear/* # log file(s)
loadkeys -d # default keyboard
rear recover # recover system
: # there are some predefined entries in the bash history
EOF

chmod $v 0644 $ROOTFS_DIR/$ROOT_HOME_DIR/.bash_history
# Create bash history file or append to an existing one:
Log "Creating or appending to $ROOTFS_DIR/$ROOT_HOME_DIR/.bash_history"
# Use get_path to check if nano and vi are available on the original system
# (and redirect its stdout to stderr to not get its stdout in .bash_history)
# because get_path is also used in build/GNU/Linux/390_copy_binaries_libraries.sh
# where nano and vi may get coiped via PROGS into the ReaR recovery system,
# cf. https://github.com/rear/rear/issues/3151#issuecomment-1941544530
# and see https://github.com/rear/rear/pull/1306 regarding nano
# and https://github.com/rear/rear/issues/1298 when vi is not available.
# Use the |--...--| ruler below so entries fit in a 80 characters line
# so that it looks OK even on a console with 80 characters per line.
# The ReaR recovery system bash prompt is: 'RESCUE $HOSTNAME:~ # '
# that has about 20 characters (depending on $HOSTNAME length)
# so about 60 characters are left to show bash history entries
# |------------------------------------------------------------|
{ echo ": # no more predefined ReaR entries in the bash history"
echo "systemctl start sshd.service # start SSH"
echo "ip -4 addr # IPv4 address"
echo "dhcpcd eth0 # start DHCP"
if get_path nano 1>&2 ; then
echo "nano /var/lib/rear/layout/diskrestore.sh # disk restore"
echo "nano /var/lib/rear/layout/disklayout.conf # disk layout"
fi
if get_path vi 1>&2 ; then
echo "vi /var/lib/rear/layout/diskrestore.sh # disk restore"
echo "vi /var/lib/rear/layout/disklayout.conf # disk layout"
fi
echo "less /var/log/rear/* # log file(s)"
echo "loadkeys -d # default keymap"
echo "rear recover # recover system"
echo ": # there are some predefined entries in the bash history"
} >> $ROOTFS_DIR/$ROOT_HOME_DIR/.bash_history

# any other dot files should be listed below
# Other dot files should be listed below:
2 changes: 0 additions & 2 deletions usr/share/rear/skel/default/root/.gitignore

This file was deleted.

1 change: 1 addition & 0 deletions usr/share/rear/skel/default/root/.vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 700727b

Please sign in to comment.