Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
f6d56dd3
Commit
f6d56dd3
authored
8 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Added bashrc file (refs
#20747
).
parent
13444536
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
1.Base/1.Utilities/0_setup.py
+3
-48
3 additions, 48 deletions
1.Base/1.Utilities/0_setup.py
1.Base/1.Utilities/bashrc
+122
-0
122 additions, 0 deletions
1.Base/1.Utilities/bashrc
1.Base/2.ubicast_shell_access/0_setup.py
+2
-0
2 additions, 0 deletions
1.Base/2.ubicast_shell_access/0_setup.py
with
127 additions
and
48 deletions
1.Base/1.Utilities/0_setup.py
+
3
−
48
View file @
f6d56dd3
...
...
@@ -6,6 +6,7 @@ import utils
def
setup
(
interactive
=
True
):
dir_path
=
utils
.
get_dir
(
__file__
)
cmds
=
[
'
apt-get clean
'
,
'
apt-get update
'
,
...
...
@@ -15,53 +16,7 @@ def setup(interactive=True):
'
update-locale LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
'
,
# Vim colors
'
[ -f ~/.vimrc ] || echo
"
color ron
"
> ~/.vimrc
'
,
# Copy bashrc file
'
cp
"
%s/bashrc
"
"
/root/.bashrc
"'
%
dir_path
,
]
utils
.
run_commands
(
cmds
)
# Add settings in bashrc
lines
=
'''
# Colors
alias ls=
'
ls --color=auto
'
alias grep=
'
grep --color=auto
'
alias fgrep=
'
fgrep --color=auto
'
alias egrep=
'
egrep --color=auto
'
# PS
PS1=
'
${debian_chroot:+($debian_chroot)}
\\
[
\\
033[01;32m
\\
]
\\
u@
\\
h
\\
[
\\
033[00m
\\
]:
\\
[
\\
033[01;34m
\\
]
\\
w
\\
[
\\
033[00m
\\
]
\\
$
'
# ls
alias ll=
'
ls -alF
'
alias la=
'
ls -A
'
alias l=
'
ls -CF
'
# system
alias lskernels=
'
dpkg --get-selections | grep linux
'
alias lspackages=
'
dpkg --get-selections
'
alias swapclear=
'
sudo swapoff -a && sudo swapon -a
'
alias full-upgrade=
'
sudo apt-get update && sudo apt-get dist-upgrade -y
'
alias aptud=
'
sudo apt-get update
'
alias aptug=
'
sudo apt-get upgrade
'
# python
alias rmpyc=
'
find . -name *.pyc -type f -delete && find . -name __pycache__ -type d -delete
'
function cp_to_monitor() {
url=`grep server_name /etc/nginx/sites-enabled/msmonitor.conf | tail -n 1 | cut -f 2 | cut -d
"
"
-f 2`
url=
"
${url::-1}
"
echo
"
cp $1 /home/msmonitor/msmonitor/logs/$1
"
cp $1 /home/msmonitor/msmonitor/logs/$1
echo
"
Files are available here: https://$url/storage/
"
}
'''
bashrc_path
=
os
.
path
.
expanduser
(
'
~/.bashrc
'
)
bashrc
=
''
if
os
.
path
.
exists
(
bashrc_path
):
with
open
(
bashrc_path
,
'
r
'
)
as
fo
:
bashrc
=
fo
.
read
()
new_bashrc
=
bashrc
.
replace
(
'
#force_color_prompt=yes
'
,
'
force_color_prompt=yes
'
)
for
line
in
lines
.
split
(
'
\n
'
):
line
=
line
.
strip
()
if
'
=
'
in
line
:
name
=
line
.
split
(
'
=
'
)[
0
]
+
'
=
'
if
name
not
in
new_bashrc
:
new_bashrc
+=
'
\n
'
+
line
if
new_bashrc
!=
bashrc
:
new_bashrc
+=
'
\n
'
with
open
(
bashrc_path
,
'
w
'
)
as
fo
:
fo
.
write
(
new_bashrc
)
utils
.
log
(
'
bashrc file updated: %s
'
%
bashrc_path
)
utils
.
log
(
'
bashrc file up to date.
'
)
This diff is collapsed.
Click to expand it.
1.Base/1.Utilities/bashrc
0 → 100644
+
122
−
0
View file @
f6d56dd3
#!/bin/bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[
-z
"
$PS1
"
]
&&
return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL
=
ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt
-s
histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE
=
10000
HISTFILESIZE
=
20000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt
-s
checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[
-x
/usr/bin/lesspipe
]
&&
eval
"
$(
SHELL
=
/bin/sh lesspipe
)
"
# set variable identifying the chroot you work in (used in the prompt below)
if
[
-z
"
$debian_chroot
"
]
&&
[
-r
/etc/debian_chroot
]
;
then
debian_chroot
=
$(
cat
/etc/debian_chroot
)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case
"
$TERM
"
in
xterm-color
)
color_prompt
=
yes
;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt
=
yes
if
[
-n
"
$force_color_prompt
"
]
;
then
if
[
-x
/usr/bin/tput
]
&&
tput setaf 1
>
&/dev/null
;
then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt
=
yes
else
color_prompt
=
fi
fi
if
[
"
$color_prompt
"
=
yes
]
;
then
PS1
=
'${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1
=
'${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset
color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case
"
$TERM
"
in
xterm
*
|
rxvt
*
)
PS1
=
"
\[\e
]0;
${
debian_chroot
:+
(
$debian_chroot
)
}
\u
@
\h
:
\w\a\]
$PS1
"
;;
*
)
;;
esac
# enable color support of ls and also add handy aliases
if
[
-x
/usr/bin/dircolors
]
;
then
test
-r
~/.dircolors
&&
eval
"
$(
dircolors
-b
~/.dircolors
)
"
||
eval
"
$(
dircolors
-b
)
"
alias ls
=
'ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep
=
'grep --color=auto'
alias
fgrep
=
'fgrep --color=auto'
alias
egrep
=
'egrep --color=auto'
alias
rgrep
=
'rgrep --color=auto'
fi
# some more ls aliases
alias
ll
=
'ls -alF'
alias
lh
=
'ls -alFh'
alias
la
=
'ls -A'
alias
l
=
'ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if
[
-f
~/.bash_aliases
]
;
then
.
~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi
# system
alias
lskernels
=
'dpkg --get-selections | grep linux'
alias
lspackages
=
'dpkg --get-selections'
alias
swapclear
=
'sudo swapoff -a && sudo swapon -a'
alias
full-upgrade
=
'sudo apt-get update && sudo apt-get dist-upgrade -y'
alias
aptud
=
'sudo apt-get update'
alias
aptug
=
'sudo apt-get upgrade'
# python
alias
rmpyc
=
'find . -name *.pyc -type f -delete && find . -name __pycache__ -type d -delete'
# send a file to the dir served by monitor on https
function
cp_to_monitor
()
{
url
=
`
grep
server_name /etc/nginx/sites-enabled/msmonitor.conf |
tail
-n
1 |
cut
-f
2 |
cut
-d
" "
-f
2
`
url
=
"
${
url
::-1
}
"
echo
"cp
$1
/home/msmonitor/msmonitor/logs/
$1
"
cp
$1
/home/msmonitor/msmonitor/logs/
$1
echo
"Files are available here: https://
$url
/storage/"
}
This diff is collapsed.
Click to expand it.
1.Base/2.ubicast_shell_access/0_setup.py
+
2
−
0
View file @
f6d56dd3
...
...
@@ -27,6 +27,7 @@ def setup(interactive=True):
else
:
utils
.
log
(
'
The key
"
ubicast_support.pub
"
is already in /root/.ssh/authorized_keys.
'
)
# ubicast
cmds
.
append
(
'
mkdir -p /home/ubicast
'
)
cmds
.
append
(
'
mkdir -p /home/ubicast/.ssh
'
)
cmds
.
append
(
'
chmod 700 /home/ubicast/.ssh
'
)
code
,
out
=
utils
.
exec_cmd
([
'
rgrep
'
,
'
support@ubicast
'
,
'
/home/ubicast/.ssh
'
])
...
...
@@ -34,6 +35,7 @@ def setup(interactive=True):
cmds
.
append
(
'
cat
"
%s/ubicast_support.pub
"
>> /home/ubicast/.ssh/authorized_keys
'
%
dir_path
)
else
:
utils
.
log
(
'
The key
"
ubicast_support.pub
"
is already in /home/ubicast/.ssh/authorized_keys.
'
)
cmds
.
append
(
'
cp
"
/root/.bashrc
"
"
/home/ubicast/.bashrc
"'
)
cmds
.
append
(
'
chown -R ubicast:ubicast /home/ubicast/.ssh
'
)
utils
.
run_commands
(
cmds
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment