Pogoplug: diferència entre les revisions

De WikiMar
Salta a la navegació Salta a la cerca
(Tornant a la versio 1206 per error del format)
Línia 1: Línia 1:
<h1>How to configure a Pogoplug E02 into a NAS server with Rsync, Samba, HDD Automounting, etc., while keeping the Pogoplug services</h1>
=How to configure a Pogoplug E02 into a NAS server with Rsync, Samba, HDD Automounting, etc., while keeping the Pogoplug services=
<h2>Backup your Pogoplug system</h2>
 
<p>(optional)
==Backup your Pogoplug system==
</p><p><br />
(optional)
</p>
 
<h2>Install ArchLinux</h2>
 
<p>http://archlinuxarm.org/platforms/armv5/pogoplug-v2-pinkgray
==Install ArchLinux==
</p><p>Backup of the URL above:
http://archlinuxarm.org/platforms/armv5/pogoplug-v2-pinkgray
</p>
 
Backup of the URL above:
<pre>
<pre>
With the device on and online, attempt to SSH to the IP the device received through DHCP. If you are unable to SSH, register and enable SSH through my.pogoplug.com. The default login (unless changed through my.pogoplug.com) is root/ceadmin.
With the device on and online, attempt to SSH to the IP the device received through DHCP. If you are unable to SSH, register and enable SSH through my.pogoplug.com. The default login (unless changed through my.pogoplug.com) is root/ceadmin.
Línia 49: Línia 50:
Log back in after your Pogoplug reboots using username root and password root.
Log back in after your Pogoplug reboots using username root and password root.
</pre>
</pre>
<p><br />
 
</p>
 
<h2>Initial setup</h2>
==Initial setup==
<p>http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/
 
</p><p>After Archlinix installed, login via SSH:
http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/
</p>
 
<pre class="_fck_mw_lspace">username: root
After Archlinix installed, login via SSH:
password: root
username: root
</pre>
password: root
<p>Cahnge root password:
 
</p>
Cahnge root password:
<pre class="_fck_mw_lspace">passwd root
passwd root
</pre>
 
<p>Updade the packet repository:
Updade the packet repository:
</p>
pacman -Syu
<pre class="_fck_mw_lspace">pacman -Syu
pacman -Syu
pacman -Syu
 
</pre>
Choose a hostname:
<p>Choose a hostname:
hostnamectl set-hostname ocell
</p>
 
<pre class="_fck_mw_lspace">hostnamectl set-hostname ocell
Select correct timezone:
</pre>
timedatectl set-timezone Europe/Berlin
<p>Select correct timezone:
 
</p>
Keep time updated (it may be already done):
<pre class="_fck_mw_lspace">timedatectl set-timezone Europe/Berlin
pacman -S openntpd
</pre>
systemctl enable openntpd
<p>Keep time updated (it may be already done):
 
</p>
Some extra useful tools:
<pre class="_fck_mw_lspace">pacman -S openntpd
pacman -S sdparm
systemctl enable openntpd
pacman -S hd-idle
</pre>
pacman -S mc
<p>Some extra useful tools:
pacman -S vim
</p>
 
<pre class="_fck_mw_lspace">pacman -S sdparm
pacman -S rsync
pacman -S hd-idle
pacman -S unison
pacman -S mc
pacman -S autossh
pacman -S vim
 
</pre>
pacman -S screen
<pre class="_fck_mw_lspace">pacman -S rsync
 
pacman -S unison
==Add more users and setup sudo access==
pacman -S autossh
useradd marti
</pre>
..
<pre class="_fck_mw_lspace">pacman -S screen
useradd rsync
</pre>
 
<h2>Add more users and setup sudo access</h2>
mkdir /home/marti
<pre class="_fck_mw_lspace">useradd marti
mkdir /home/rsync
</pre>
 
<p>..
cd /home/rsync
</p>
mkdir .ssh
<pre class="_fck_mw_lspace">useradd rsync
nano authorized_keys
</pre>
chmod 600 authorized_keys
<pre class="_fck_mw_lspace">mkdir /home/marti
 
mkdir /home/rsync
chown marti:marti /home/marti
</pre>
chown rsync:rsync /home/rsync
<pre class="_fck_mw_lspace">cd /home/rsync
 
mkdir .ssh
groupadd sudo
nano authorized_keys
usermod -a -G sudo marti
chmod 600 authorized_keys
pacman -S sudo
</pre>
visudo
<pre class="_fck_mw_lspace">chown marti:marti /home/marti
add
chown rsync:rsync /home/rsync
%sudo ALL=(ALL) ALL
</pre>
 
<pre class="_fck_mw_lspace">groupadd sudo
Editar i activar hd-idle
usermod -a -G sudo marti
sudo vim /etc/conf.d/hd-idle
pacman -S sudo
 
visudo
==Set up Munin for system monitoring==
</pre>
pacman -S munin-node
<p>add
 
</p>
nano /etc/munin/munin-node.con
<pre class="_fck_mw_lspace">%sudo ALL=(ALL) ALL
add:
</pre>
allow ^212\.83\.63\.165$
<p>Editar i activar hd-idle
 
</p>
 
<pre class="_fck_mw_lspace">sudo vim /etc/conf.d/hd-idle
munin-node-configure --shell | sh
</pre>
more info: munin-node-configure --suggest
<h2>Set up Munin for system monitoring</h2>
systemctl start munin-node
<pre class="_fck_mw_lspace">pacman -S munin-node
systemctl enable munin-node
</pre>
 
<pre class="_fck_mw_lspace">nano /etc/munin/munin-node.con
 
</pre>
==Keep a reverse tunnel up to reach the NAS system even when it's installed undere a NAT==
<p>add:
nano /root/tunnel-start.sh
</p>
<pre class="_fck_mw_lspace">allow ^212\.83\.63\.165$
</pre>
<p><br />
</p>
<pre class="_fck_mw_lspace">munin-node-configure --shell | sh
</pre>
<p>more info: munin-node-configure --suggest
</p>
<pre class="_fck_mw_lspace">systemctl start munin-node
systemctl enable munin-node
</pre>
<p><br />
</p>
<h2>Keep a reverse tunnel up to reach the NAS system even when it's installed undere a NAT</h2>
<pre class="_fck_mw_lspace">nano /root/tunnel-start.sh
</pre>
<pre>
<pre>
#!/bin/bash
#!/bin/bash


LOGFILE=&quot;/root/tunnel-start.log&quot;
LOGFILE="/root/tunnel-start.log"
DATE=$(date +'%Y-%m-%d&nbsp;%H:%M:%S')
DATE=$(date +'%Y-%m-%d %H:%M:%S')


while [ 1 ]; do
while [ 1 ]; do
  echo &quot;$DATE - Starting autossh&quot; &gt;&gt; $LOGFILE
  echo "$DATE - Starting autossh" >> $LOGFILE
  autossh -M 0 -q -N -o &quot;ServerAliveInterval 60&quot; -o &quot;ServerAliveCountMax 3&quot; -g -R 0.0.0.0:3322:localhost:22 -R 0.0.0.0:3349:localhost:4949 -p23 [email protected]
  autossh -M 0 -q -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -g -R 0.0.0.0:3322:localhost:22 -R 0.0.0.0:3349:localhost:4949 -p23 [email protected]
  sleep 5
  sleep 5
done
done
</pre>
</pre>
<p><br />
 
</p>
 
<pre class="_fck_mw_lspace">nano /etc/cron.hourly/tunnel-hook
nano /etc/cron.hourly/tunnel-hook
</pre>
<pre>
<pre>
#!/bin/bash
#!/bin/bash
COMMAND=&quot;/root/tunnel-start.sh&quot;
COMMAND="/root/tunnel-start.sh"
LOGFILE=&quot;/root/tunnel-start.log&quot;
LOGFILE="/root/tunnel-start.log"
DATE=$(date +'%Y-%m-%d&nbsp;%H:%M:%S')
DATE=$(date +'%Y-%m-%d %H:%M:%S')


if [ &quot;$(ps ax | grep tunnel-start.sh | grep -vc grep)&quot; -lt 1 ]; then
if [ "$(ps ax | grep tunnel-start.sh | grep -vc grep)" -lt 1 ]; then
     echo &quot;$DATE - Starting tunnel-start.sh&quot; &gt;&gt; $LOGFILE
     echo "$DATE - Starting tunnel-start.sh" >> $LOGFILE
     $COMMAND &amp;
     $COMMAND &
     exit
     exit
fi
fi
</pre>
</pre>
<p><br />
 
</p>
 
<pre class="_fck_mw_lspace">nano /usr/lib/systemd/system/marti-tunnel.service
 
</pre>
nano /usr/lib/systemd/system/marti-tunnel.service
<pre>
<pre>
[Unit]
[Unit]
Línia 193: Línia 176:
WantedBy=multi-user.target
WantedBy=multi-user.target
</pre>
</pre>
<pre class="_fck_mw_lspace">systemctl enable marti-tunnel
 
</pre>
systemctl enable marti-tunnel
<h2>Install Webmin</h2>
 
<pre class="_fck_mw_lspace">pacman -Sy webmin perl-net-ssleay
==Install Webmin==
</pre>
 
<pre class="_fck_mw_lspace">nano /etc/webmin/miniserv.conf
pacman -Sy webmin perl-net-ssleay
</pre>
 
<p>afegir:
nano /etc/webmin/miniserv.conf
</p>
afegir:
<pre class="_fck_mw_lspace">allow=192.168.0.0
allow=192.168.0.0
</pre>
 
<pre class="_fck_mw_lspace">systemctl enable webmin
systemctl enable webmin
systemctl start webmin
systemctl start webmin
</pre>
 
<p><br />
 
https://deviceip:10000
https://deviceip:10000
To lower memory usage go to:
To lower memory usage go to:
Webmin&gt;Webmin Configuration&gt;Advanced Configuration and disable “Pre-load Webmin functions library?”
Webmin>Webmin Configuration>Advanced Configuration and disable “Pre-load Webmin functions library?”
</p><p><br />
 
</p>
 
<h2>Disks automount</h2>
==Disks automount==
<pre class="_fck_mw_lspace">pacman -Sy udevil
pacman -Sy udevil
</pre>
 
<pre class="_fck_mw_lspace">nano /etc/udevil/udevil.conf
nano /etc/udevil/udevil.conf
</pre>
Search for default_options_ntfs= and allowed_options=
<p>Search for default_options_ntfs= and allowed_options=
Now we add the option “big_writes” to both lines so it looks like:
Now we add the option “big_writes” to both lines so it looks like:
</p>
..., noatime, big_writes, uid=...
<pre class="_fck_mw_lspace">..., noatime, big_writes, uid=...
 
</pre>
 
<p><br />
mkdir /media
</p>
 
<pre class="_fck_mw_lspace">mkdir /media
systemctl enable devmon@root
</pre>
or better, so that the rsync user can set times and perms (use "--modify-window=2 --no-perms" in rsync):
<pre class="_fck_mw_lspace">systemctl enable devmon@root
systemctl enable devmon@rsync
</pre>
 
<p>or better, so that the rsync user can set times and perms (use "--modify-window=2 --no-perms" in rsync):
reboot
</p>
 
<pre class="_fck_mw_lspace">systemctl enable devmon@rsync
==Samba==
</pre>
 
<pre class="_fck_mw_lspace">reboot
 
</pre>
==Colors==
<h2>Samba</h2>
 
<h2>Colors</h2>
mv /etc/bash.bashrc /etc/bash.bashrc-ORIGINAL
<pre class="_fck_mw_lspace">mv /etc/bash.bashrc /etc/bash.bashrc-ORIGINAL
nano /etc/bash.bashrc
nano /etc/bash.bashrc
 
</pre>
<pre>
<pre>
# /etc/bash.bashrc
# /etc/bash.bashrc
Línia 248: Línia 229:
# including some apparently interactive shells such as scp and rcp
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen&nbsp;!
# anything or bad things will happen !


# Test for an interactive shell. There is no need to set anything
# Test for an interactive shell. There is no need to set anything
Línia 255: Línia 236:


# If not running interactively, don't do anything!
# If not running interactively, don't do anything!
[[ $-&nbsp;!= *i* ]] &amp;&amp; return
[[ $- != *i* ]] && return


# Bash won't get SIGWINCH if another process is in the foreground.
# Bash won't get SIGWINCH if another process is in the foreground.
Línia 268: Línia 249:
case ${TERM} in
case ${TERM} in
         xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
         xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
                 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033]0;%s@%s:%s\007&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'
                 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
              &nbsp;;;
                ;;
         screen)
         screen)
                 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf &quot;\033_%s@%s:%s\033\\&quot; &quot;${USER}&quot; &quot;${HOSTNAME%%.*}&quot; &quot;${PWD/#$HOME/~}&quot;'
                 PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
              &nbsp;;;
                ;;
esac
esac


# fortune is a simple program that displays a pseudorandom message
# fortune is a simple program that displays a pseudorandom message
# from a database of quotations at logon and/or logout.
# from a database of quotations at logon and/or logout.
# Type: &quot;pacman -S fortune-mod&quot; to install it, then uncomment the
# Type: "pacman -S fortune-mod" to install it, then uncomment the
# following line:
# following line:


# [[ &quot;$PS1&quot; ]] &amp;&amp; /usr/bin/fortune
# [[ "$PS1" ]] && /usr/bin/fortune


# Welcome Message
# Welcome Message
# Arch Linux Logo Welcome Message
# Arch Linux Logo Welcome Message
c1=&quot;$(tput sgr0)$(tput setaf 4)&quot;
c1="$(tput sgr0)$(tput setaf 4)"
c2=&quot;$(tput bold)$(tput setaf 4)&quot;
c2="$(tput bold)$(tput setaf 4)"
c3=&quot;$(tput bold)$(tput setaf 7)&quot;
c3="$(tput bold)$(tput setaf 7)"
echo
echo
echo &quot;       $c2,$c1                      _    _ _&quot;
echo "       $c2,$c1                      _    _ _"
echo &quot;       $c2/$c1#$c2\\$c1        __ _ _ __ ___| |__ | (_)_ __  _  ___  __&quot;
echo "       $c2/$c1#$c2\\$c1        __ _ _ __ ___| |__ | (_)_ __  _  ___  __"
echo &quot;     $c2/$c1###$c2\\$c1      / _\` | '__/ __| '_ \\| | | '_ \\| | | \\ \\/ /&quot;
echo "     $c2/$c1###$c2\\$c1      / _\` | '__/ __| '_ \\| | | '_ \\| | | \\ \\/ /"
echo &quot;     $c2/$c1#####$c2\\$c1    | (_| | | | (__| | | | | | | | | |_| |&gt; &lt;&quot;
echo "     $c2/$c1#####$c2\\$c1    | (_| | | | (__| | | | | | | | | |_| |> <"
echo &quot;   $c2/$c1##,-,##$c2\\$c1    \\__,_|_|  \\___|_| |_|_|_|_| |_|\\__,_/_/\\_\\&quot;
echo "   $c2/$c1##,-,##$c2\\$c1    \\__,_|_|  \\___|_| |_|_|_|_| |_|\\__,_/_/\\_\\"
echo &quot;   $c2/$c1##(  )##$c2\\$c1&quot;
echo "   $c2/$c1##(  )##$c2\\$c1"
echo &quot; $c2/$c1#.--  --.#$c2\\  $c3 A simple, elegant GNU/Linux distribution.&quot;
echo " $c2/$c1#.--  --.#$c2\\  $c3 A simple, elegant GNU/Linux distribution."
echo &quot; $c2/$c1\`          \`$c2\\$(tput sgr0)&quot;$'\n'
echo " $c2/$c1\`          \`$c2\\$(tput sgr0)"$'\n'


# Show date
# Show date
DATE=&quot;$(tput setaf 1)[$(tput setaf 6)$(date)&quot;
DATE="$(tput setaf 1)[$(tput setaf 6)$(date)"
DATE=&quot;${DATE}$(tput setaf 1)]&quot;
DATE="${DATE}$(tput setaf 1)]"
echo $DATE
echo $DATE
# Show kernel info
# Show kernel info
KERNEL=&quot;$(tput setaf 1)[$(tput setaf 6)$(uname -srmn)&quot;
KERNEL="$(tput setaf 1)[$(tput setaf 6)$(uname -srmn)"
KERNEL=&quot;${KERNEL}$(tput setaf 1)]&quot;
KERNEL="${KERNEL}$(tput setaf 1)]"
echo &quot;$KERNEL&quot;$'\n'
echo "$KERNEL"$'\n'
# Reset colors
# Reset colors
tput sgr0
tput sgr0
Línia 316: Línia 297:
# sanitize TERM:
# sanitize TERM:
safe_term=${TERM//[^[:alnum:]]/?}
safe_term=${TERM//[^[:alnum:]]/?}
match_lhs=&quot;&quot;
match_lhs=""


[[ -f ~/.dir_colors ]] &amp;&amp; match_lhs=&quot;${match_lhs}$(&lt;~/.dir_colors)&quot;
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] &amp;&amp; match_lhs=&quot;${match_lhs}$(&lt;/etc/DIR_COLORS)&quot;
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
[[ -z ${match_lhs} ]] \
         &amp;&amp; type -P dircolors &gt;/dev/null \
         && type -P dircolors >/dev/null \
         &amp;&amp; match_lhs=$(dircolors --print-database)
         && match_lhs=$(dircolors --print-database)


if [[ $'\n'${match_lhs} == *$'\n'&quot;TERM &quot;${safe_term}* ]]&nbsp;; then
if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then


         # we have colors &lt;img src=&quot;http://obihoernchen.net/wordpress/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:-)&quot; class=&quot;wp-smiley&quot;&gt;
         # we have colors <img src="http://obihoernchen.net/wordpress/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley">


         # Enable colors for ls, etc. Prefer ~/.dir_colors
         # Enable colors for ls, etc. Prefer ~/.dir_colors
         if type -P dircolors &gt;/dev/null&nbsp;; then
         if type -P dircolors >/dev/null ; then
                 if [[ -f ~/.dir_colors ]]&nbsp;; then
                 if [[ -f ~/.dir_colors ]] ; then
                         eval $(dircolors -b ~/.dir_colors)
                         eval $(dircolors -b ~/.dir_colors)
                 elif [[ -f /etc/DIR_COLORS ]]&nbsp;; then
                 elif [[ -f /etc/DIR_COLORS ]] ; then
                         eval $(dircolors -b /etc/DIR_COLORS)
                         eval $(dircolors -b /etc/DIR_COLORS)
                 fi
                 fi
Línia 339: Línia 320:
         # -- CUSTOM PS1 String START --
         # -- CUSTOM PS1 String START --


         PS1=&quot;\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$?&nbsp;!= 0 ]] &amp;&amp; echo \&quot;[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\&quot;)[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\076 \[\033[0m\]&quot;
         PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\076 \[\033[0m\]"
         # --- Custom PS1 String END ---
         # --- Custom PS1 String END ---


         # Use this other PS1 string if you want \W for root and \w for all other users:
         # Use this other PS1 string if you want \W for root and \w for all other users:
         # PS1=&quot;$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$?&nbsp;!= 0 ]] &amp;&amp; echo \&quot;\[\033[01;31m\]:(\[\033[01;34m\] \&quot;)\$\[\033[00m\] &quot;
         # PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "


         alias ls=&quot;ls --color=auto&quot;
         alias ls="ls --color=auto"
         alias dir=&quot;dir --color=auto&quot;
         alias dir="dir --color=auto"
         alias grep=&quot;grep --colour=auto&quot;
         alias grep="grep --colour=auto"


else
else
Línia 353: Línia 334:
         # show root@ when we do not have colors
         # show root@ when we do not have colors


         PS1=&quot;\u@\h \w \$([[ \$?&nbsp;!= 0 ]] &amp;&amp; echo \&quot;:( \&quot;)\$ &quot;
         PS1="\u@\h \w \$([[ \$? != 0 ]] && echo \":( \")\$ "


         # Use this other PS1 string if you want \W for root and \w for all other users:
         # Use this other PS1 string if you want \W for root and \w for all other users:
         # PS1=&quot;\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$?&nbsp;!= 0 ]] &amp;&amp; echo \&quot;:( \&quot;)\$ &quot;
         # PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] && echo \":( \")\$ "


fi
fi


PS2=&quot;&gt; &quot;
PS2="> "
PS3=&quot;&gt; &quot;
PS3="> "
PS4=&quot;+ &quot;
PS4="+ "


# Try to keep environment pollution down, EPA loves us.
# Try to keep environment pollution down, EPA loves us.
unset safe_term match_lhs
unset safe_term match_lhs


# Try to enable the auto-completion (type: &quot;pacman -S bash-completion&quot; to install it).
# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).
[ -r /usr/share/bash-completion/bash_completion ] &amp;&amp; . /usr/share/bash-completion/bash_completion
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion


# Try to enable the &quot;Command not found&quot; hook (&quot;pacman -S pkgfile&quot; to install it).
# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] &amp;&amp; . /usr/share/doc/pkgfile/command-not-found.bash
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash




# Afegit Marti:
# Afegit Marti:


if [[ ${EUID} == 0 ]]&nbsp;; then
if [[ ${EUID} == 0 ]] ; then
   PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
   PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
else
Línia 384: Línia 365:


# If this is an xterm set the title to user@host:dir
# If this is an xterm set the title to user@host:dir
case &quot;$TERM&quot; in
case "$TERM" in
xterm*|rxvt*)
xterm*|rxvt*)
   PS1=&quot;\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1&quot;
   PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
  &nbsp;;;
  ;;
*)
*)
  &nbsp;;;
  ;;
esac
esac


# enable color support of ls and also add handy aliases
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
if [ -x /usr/bin/dircolors ]; then
     test -r ~/.dircolors &amp;&amp; eval &quot;$(dircolors -b ~/.dircolors)&quot; || eval &quot;$(dircolors -b)&quot;
     test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
     alias ls='ls --color=auto'
     alias ls='ls --color=auto'
     alias dir='dir --color=auto'
     alias dir='dir --color=auto'
Línia 408: Línia 389:


</pre>
</pre>
<p><br />
 
</p>
 
<pre class="_fck_mw_lspace">nano /etc/DIR_COLORS
nano /etc/DIR_COLORS
</pre>
 
<pre>
<pre>
# Configuration file for the color ls utility
# Configuration file for the color ls utility
Línia 500: Línia 481:


</pre>
</pre>
<h2>Samba</h2>
 
<p>More info: http://blog.qnology.com/2013/03/tutorial-pogoplug-e02-with-arch-linux.html
==Samba==
</p>
More info: http://blog.qnology.com/2013/03/tutorial-pogoplug-e02-with-arch-linux.html
<pre class="_fck_mw_lspace">pacman -Sy samba
 
</pre>
pacman -Sy samba
<pre class="_fck_mw_lspace">cd /etc/samba
 
wget http://dl.dropbox.com/u/42238/pogoplug/v2/smb.conf
cd /etc/samba
</pre>
wget http://dl.dropbox.com/u/42238/pogoplug/v2/smb.conf
<pre class="_fck_mw_lspace">nano /etc/samba/smb.conf
 
</pre>
nano /etc/samba/smb.conf
<pre>
<pre>
[global]
[global]
Línia 546: Línia 527:
   guest ok = yes
   guest ok = yes
</pre>
</pre>
<pre class="_fck_mw_lspace">systemctl start smbd nmbd
 
systemctl enable smbd nmbd
systemctl start smbd nmbd
</pre>
systemctl enable smbd nmbd
<p>No se si cal:
 
</p>
No se si cal:
<pre class="_fck_mw_lspace">systemctl enable samba
systemctl enable samba
groupadd samba
groupadd samba
</pre>
 
<p>....
....
</p><p><br />
 
</p>
 
<h2>REinstall my.pogoplug.com service</h2>
==REinstall my.pogoplug.com service==
<p>http://archlinuxarm.org/forum/viewtopic.php?t=3343
http://archlinuxarm.org/forum/viewtopic.php?t=3343
</p><p>Backup of the URL:
 
</p>
Backup of the URL:
<pre>
<pre>
Updated: May 28 2013
Updated: May 28 2013
Línia 577: Línia 558:
1. Run  
1. Run  
CODE: SELECT ALL
CODE: SELECT ALL
/usr/local/cloudengines/bin/hbplug | grep &quot;Device ID&quot;
/usr/local/cloudengines/bin/hbplug | grep "Device ID"


and take note of the shown Device ID. We are interested in this line, particularly the string in red  
and take note of the shown Device ID. We are interested in this line, particularly the string in red  
Línia 585: Línia 566:
nano /usr/local/cloudengines/bin/hbplug.conf
nano /usr/local/cloudengines/bin/hbplug.conf


the line &quot;svcid=&quot; should now be &quot;svcid=8C3CUTEY6MNGHLCV9FYVUNEZCN&quot;
the line "svcid=" should now be "svcid=8C3CUTEY6MNGHLCV9FYVUNEZCN"
3. Now run
3. Now run
CODE: SELECT ALL
CODE: SELECT ALL
/usr/local/cloudengines/bin/hbplug | grep &quot;CRYPTO&quot;
/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
several times until it reads CRYPTO KEY: VALID
several times until it reads CRYPTO KEY: VALID
Wait a reasonable amount of time before CTRL+C'ing it (60 sec?)
Wait a reasonable amount of time before CTRL+C'ing it (60 sec?)
Línia 599: Línia 580:


A couple of points:
A couple of points:
- config file location /etc/pogoplug.conf --&gt; EDIT IT to get directories visible at my.pogoplug.com
- config file location /etc/pogoplug.conf --> EDIT IT to get directories visible at my.pogoplug.com
- Format: vfsdir&lt;number&gt;=&lt;name&gt;,&lt;path&gt;
- Format: vfsdir<number>=<name>,<path>
- Example: vfsdir0=plugdata,/media/2TBDrive/Downloads
- Example: vfsdir0=plugdata,/media/2TBDrive/Downloads
- Don't change order of variables. Add more directories under each other. E.g Line1: vfsdir0=.. Line2: vfsdir1=..
- Don't change order of variables. Add more directories under each other. E.g Line1: vfsdir0=.. Line2: vfsdir1=..
Línia 607: Línia 588:
Don't forget to (re)register your device at my.pogoplug.com.  
Don't forget to (re)register your device at my.pogoplug.com.  
</pre>
</pre>
<p><br />
 
 
Steps followed:
Steps followed:
</p><p><br />
 
</p>
 
<pre class="_fck_mw_lspace">pacman -U http://dl.dropboxusercontent.com/u/15043728/ArchLinuxArm/pogoplug-3.3.0-5-arm.pkg.tar.xz
pacman -U http://dl.dropboxusercontent.com/u/15043728/ArchLinuxArm/pogoplug-3.3.0-5-arm.pkg.tar.xz
</pre>
 
<pre class="_fck_mw_lspace">nano /usr/local/cloudengines/hbplug.conf
nano /usr/local/cloudengines/hbplug.conf
</pre>
edit
<p>edit
installdir=/usr/local/cloudengines
</p>
datadir=./T3000_64k_Backup_U/
<pre class="_fck_mw_lspace">installdir=/usr/local/cloudengines
vfsdir0=PogoPlug_USB,/media
datadir=./T3000_64k_Backup_U/
nohotplug=1
vfsdir0=PogoPlug_USB,/media
svcid=53UFGEBGD77LEYKX73YFCM6XPW
nohotplug=1
 
svcid=53UFGEBGD77LEYKX73YFCM6XPW
ocell2
</pre>
3WQMBM9WNJ32H25LKGWHDDCDP6
<p>ocell2
 
</p>
/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
<pre class="_fck_mw_lspace">3WQMBM9WNJ32H25LKGWHDDCDP6
/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
</pre>
 
<pre class="_fck_mw_lspace">/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
mv /usr/local/cloudengines/hbplug.conf /etc/pogoplug.conf
/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
 
</pre>
systemctl enable pogoplug
<pre class="_fck_mw_lspace">mv /usr/local/cloudengines/hbplug.conf /etc/pogoplug.conf
 
</pre>
==Update Kernel==
<pre class="_fck_mw_lspace">systemctl enable pogoplug
Optional (Not sure if it's needed).
</pre>
 
<h2>Update Kernel</h2>
http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/
<p>Optional (Not sure if it's needed).
 
</p><p>http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/
Backup of the URL above:
</p><p>Backup of the URL above:
</p>
<pre>
<pre>
8. Update Kernel to &gt;3.2
8. Update Kernel to >3.2
Warning: This specific instruction works for PogoplugV2 only!
Warning: This specific instruction works for PogoplugV2 only!
You can brick your device!
You can brick your device!
Línia 647: Línia 627:
You have to update manually because newer kernels need a new uboot.
You have to update manually because newer kernels need a new uboot.


You need the newest uboot to boot Kernels &gt;3.2 so you have to install it before:
You need the newest uboot to boot Kernels >3.2 so you have to install it before:
If this is a fresh installation you probably have the newest uboot already and you don’t have to do that!
If this is a fresh installation you probably have the newest uboot already and you don’t have to do that!


Línia 668: Línia 648:
reboot
reboot
</pre>
</pre>
<p><br />
 
</p>
 
<h2>Keep dynamic DNS updated from dyndns.org</h2>
==Keep dynamic DNS updated from dyndns.org==
<pre class="_fck_mw_lspace">pacman -S ddclient
pacman -S ddclient
</pre>
 
<pre class="_fck_mw_lspace">vim /etc/ddclient/ddclient.conf
vim /etc/ddclient/ddclient.conf
</pre>
 
<pre>
<pre>
# Basic HTTPS configuration file for ddclient
# Basic HTTPS configuration file for ddclient
Línia 691: Línia 671:
#custom=yes, example.com
#custom=yes, example.com
</pre>
</pre>
<p>More info: http://dyn.com/support/clients/linux/ddclient/
More info: http://dyn.com/support/clients/linux/ddclient/
</p>
 





Revisió del 23:22, 9 feb 2014

How to configure a Pogoplug E02 into a NAS server with Rsync, Samba, HDD Automounting, etc., while keeping the Pogoplug services

Backup your Pogoplug system

(optional)


Install ArchLinux

http://archlinuxarm.org/platforms/armv5/pogoplug-v2-pinkgray

Backup of the URL above:

With the device on and online, attempt to SSH to the IP the device received through DHCP. If you are unable to SSH, register and enable SSH through my.pogoplug.com. The default login (unless changed through my.pogoplug.com) is root/ceadmin.
Stop the Pogoplug software, so it doesn't interfere with the install process:killall hbwd
You only need to kill the Pogoplug service the first time you SSH in. Running the installer in the following steps disables it completely.

While connected via SSH to your plug, copy, paste, and run the following commands to download a bootloader that can boot from USB drives:
cd /tmp
wget http://jeff.doozan.com/debian/uboot/install_uboot_mtd0.sh
chmod +x install_uboot_mtd0.sh
./install_uboot_mtd0.sh
After the new bootloader is installed, you will need to use fdisk to partition a storage device. Plug in a 1GB or bigger USB drive. REMOVE ALL OTHER DRIVES. Move everything you need off of the Arch Linux ARM drive and back it up. Everything on the USB drive with be deleted and replaced with Arch Linux ARM.

Set the U-Boot variable to tell the kernel to use ext3:
/usr/sbin/fw_setenv usb_rootfstype ext3
Start fdisk on the USB drive:
/sbin/fdisk /dev/sda
At the fdisk prompt, delete old partitions and create a new one:
Type o. This will clear out any partitions on the drive.
Type p to list partitions. There should be no partitions left.
Now type n, then p for primary, 1 for the first partition on the drive, and then press ENTER, accepting default values.
Exit by typing w.
Now create the ext3 filesystem:
wget http://archlinuxarm.org/os/pogoplug/mke2fs
chmod 755 mke2fs
./mke2fs -j /dev/sda1
mkdir usb
mount /dev/sda1 usb
Download and install Arch Linux ARM:
cd usb
wget http://archlinuxarm.org/os/ArchLinuxARM-armv5te-latest.tar.gz
tar -xzvf ArchLinuxARM-armv5te-*.tar.gz  # This will take a long time
rm ArchLinuxARM-armv5te-*.tar.gz
sync  # Takes a while when using a flash drive
Clean up and reboot. Cross your fingers and hope for the best.
cd ..
umount usb
/sbin/reboot
The SSH key of your device will be different, so you need to tell Mac OS X or Linux to remove it from ~/.ssh/known_hosts before using SSH again:
ssh-keygen -R 192.168.1.123 # Use your device's IP
Log back in after your Pogoplug reboots using username root and password root.


Initial setup

http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/

After Archlinix installed, login via SSH:

username: root
password: root

Cahnge root password:

passwd root

Updade the packet repository:

pacman -Syu
pacman -Syu

Choose a hostname:

hostnamectl set-hostname ocell

Select correct timezone:

timedatectl set-timezone Europe/Berlin

Keep time updated (it may be already done):

pacman -S openntpd
systemctl enable openntpd

Some extra useful tools:

pacman -S sdparm
pacman -S hd-idle
pacman -S mc
pacman -S vim
pacman -S rsync
pacman -S unison
pacman -S autossh
pacman -S screen

Add more users and setup sudo access

useradd marti

..

useradd rsync
mkdir /home/marti
mkdir /home/rsync
cd /home/rsync
mkdir .ssh
nano authorized_keys
chmod 600 authorized_keys
chown marti:marti /home/marti
chown rsync:rsync /home/rsync
groupadd sudo
usermod -a -G sudo marti
pacman -S sudo
visudo

add

%sudo ALL=(ALL) ALL

Editar i activar hd-idle

sudo vim /etc/conf.d/hd-idle

Set up Munin for system monitoring

pacman -S munin-node
nano /etc/munin/munin-node.con

add:

allow ^212\.83\.63\.165$


munin-node-configure --shell | sh

more info: munin-node-configure --suggest

systemctl start munin-node
systemctl enable munin-node


Keep a reverse tunnel up to reach the NAS system even when it's installed undere a NAT

nano /root/tunnel-start.sh
#!/bin/bash

LOGFILE="/root/tunnel-start.log"
DATE=$(date +'%Y-%m-%d %H:%M:%S')

while [ 1 ]; do
 echo "$DATE - Starting autossh" >> $LOGFILE
 autossh -M 0 -q -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -g -R 0.0.0.0:3322:localhost:22 -R 0.0.0.0:3349:localhost:4949 -p23 [email protected]
 sleep 5
done


nano /etc/cron.hourly/tunnel-hook
#!/bin/bash
COMMAND="/root/tunnel-start.sh"
LOGFILE="/root/tunnel-start.log"
DATE=$(date +'%Y-%m-%d %H:%M:%S')

if [ "$(ps ax | grep tunnel-start.sh | grep -vc grep)" -lt 1 ]; then
    echo "$DATE - Starting tunnel-start.sh" >> $LOGFILE
    $COMMAND &
    exit
fi


nano /usr/lib/systemd/system/marti-tunnel.service
[Unit]
Description=Tunnel

[Service]
Type=oneshot
ExecStart=/etc/cron.hourly/tunnel-hook
ExecReload=/etc/cron.hourly/tunnel-hook

RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
systemctl enable marti-tunnel

Install Webmin

pacman -Sy webmin perl-net-ssleay
nano /etc/webmin/miniserv.conf

afegir:

allow=192.168.0.0
systemctl enable webmin
systemctl start webmin


https://deviceip:10000 To lower memory usage go to: Webmin>Webmin Configuration>Advanced Configuration and disable “Pre-load Webmin functions library?”


Disks automount

pacman -Sy udevil
nano /etc/udevil/udevil.conf

Search for default_options_ntfs= and allowed_options= Now we add the option “big_writes” to both lines so it looks like:

..., noatime, big_writes, uid=...


mkdir /media
systemctl enable devmon@root

or better, so that the rsync user can set times and perms (use "--modify-window=2 --no-perms" in rsync):

systemctl enable devmon@rsync
reboot

Samba

Colors

mv /etc/bash.bashrc /etc/bash.bashrc-ORIGINAL
nano /etc/bash.bashrc
# /etc/bash.bashrc
#
# https://wiki.archlinux.org/index.php/Color_Bash_Prompt
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !

# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.

# If not running interactively, don't do anything!
[[ $- != *i* ]] && return

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Enable history appending instead of overwriting.
shopt -s histappend

case ${TERM} in
        xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
                PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
                ;;
        screen)
                PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
                ;;
esac

# fortune is a simple program that displays a pseudorandom message
# from a database of quotations at logon and/or logout.
# Type: "pacman -S fortune-mod" to install it, then uncomment the
# following line:

# [[ "$PS1" ]] && /usr/bin/fortune

# Welcome Message
# Arch Linux Logo Welcome Message
c1="$(tput sgr0)$(tput setaf 4)"
c2="$(tput bold)$(tput setaf 4)"
c3="$(tput bold)$(tput setaf 7)"
echo
echo "        $c2,$c1                       _     _ _"
echo "       $c2/$c1#$c2\\$c1        __ _ _ __ ___| |__ | (_)_ __  _   ___  __"
echo "      $c2/$c1###$c2\\$c1      / _\` | '__/ __| '_ \\| | | '_ \\| | | \\ \\/ /"
echo "     $c2/$c1#####$c2\\$c1    | (_| | | | (__| | | | | | | | | |_| |>  <"
echo "    $c2/$c1##,-,##$c2\\$c1    \\__,_|_|  \\___|_| |_|_|_|_| |_|\\__,_/_/\\_\\"
echo "   $c2/$c1##(   )##$c2\\$c1"
echo "  $c2/$c1#.--   --.#$c2\\  $c3 A simple, elegant GNU/Linux distribution."
echo " $c2/$c1\`           \`$c2\\$(tput sgr0)"$'\n'

# Show date
DATE="$(tput setaf 1)[$(tput setaf 6)$(date)"
DATE="${DATE}$(tput setaf 1)]"
echo $DATE
# Show kernel info
KERNEL="$(tput setaf 1)[$(tput setaf 6)$(uname -srmn)"
KERNEL="${KERNEL}$(tput setaf 1)]"
echo "$KERNEL"$'\n'
# Reset colors
tput sgr0

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
# first to take advantage of user additions. Use internal bash
# globbing instead of external grep binary.

# sanitize TERM:
safe_term=${TERM//[^[:alnum:]]/?}
match_lhs=""

[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
        && type -P dircolors >/dev/null \
        && match_lhs=$(dircolors --print-database)

if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then

        # we have colors <img src="http://obihoernchen.net/wordpress/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley"> 

        # Enable colors for ls, etc. Prefer ~/.dir_colors
        if type -P dircolors >/dev/null ; then
                if [[ -f ~/.dir_colors ]] ; then
                        eval $(dircolors -b ~/.dir_colors)
                elif [[ -f /etc/DIR_COLORS ]] ; then
                        eval $(dircolors -b /etc/DIR_COLORS)
                fi
        fi

        # -- CUSTOM PS1 String START --

        PS1="\[\033[0;37m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[0;31m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; else echo '\[\033[0;33m\]\u\[\033[0;37m\]@\[\033[0;96m\]\h'; fi)\[\033[0;37m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;37m\]]\n\[\033[0;37m\]\342\224\224\342\224\200\342\224\200\076 \[\033[0m\]"
        # --- Custom PS1 String END ---

        # Use this other PS1 string if you want \W for root and \w for all other users:
        # PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h\[\033[01;34m\] \W'; else echo '\[\033[01;32m\]\u@\h\[\033[01;34m\] \w'; fi) \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\$\[\033[00m\] "

        alias ls="ls --color=auto"
        alias dir="dir --color=auto"
        alias grep="grep --colour=auto"

else

        # show root@ when we do not have colors

        PS1="\u@\h \w \$([[ \$? != 0 ]] && echo \":( \")\$ "

        # Use this other PS1 string if you want \W for root and \w for all other users:
        # PS1="\u@\h $(if [[ ${EUID} == 0 ]]; then echo '\W'; else echo '\w'; fi) \$([[ \$? != 0 ]] && echo \":( \")\$ "

fi

PS2="> "
PS3="> "
PS4="+ "

# Try to keep environment pollution down, EPA loves us.
unset safe_term match_lhs

# Try to enable the auto-completion (type: "pacman -S bash-completion" to install it).
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion

# Try to enable the "Command not found" hook ("pacman -S pkgfile" to install it).
# See also: https://wiki.archlinux.org/index.php/Bash#The_.22command_not_found.22_hook
[ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash


# Afegit Marti:

if [[ ${EUID} == 0 ]] ; then
  PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
  PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi

# 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'
fi

alias l='ls -alF'
alias ..='cd ..'
alias ...='cd ../..'


nano /etc/DIR_COLORS
# Configuration file for the color ls utility
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.

# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
# pipes. 'all' adds color characters to all output. 'none' shuts colorization
# off.
COLOR all

# Extra command line options for ls go here.
# Basically these ones are:
#  -F = show '/' for dirs, '*' for executables, etc.
#  -T 0 = don't trust tab spacing when formatting ls output.
OPTIONS -F -T 0

# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM xterm
TERM vt100
TERM rxvt
TERM rxvt-256color
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM rxvt-unicode-256color
TERM rxvt-unicode256

# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1

# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes: 
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00	# global default, although everything should be something.
FILE 00 	# normal file
DIR 01;34 	# directory
LINK 01;36 	# symbolic link
FIFO 40;33	# pipe
SOCK 01;35	# socket
BLK 40;33;01	# block device driver
CHR 40;33;01 	# character device driver

# This is for files with execute permission:
EXEC 01;32 

# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
.cmd 01;32 # executables (bright green)
.exe 01;32
.com 01;32
.btm 01;32
.bat 01;32
.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z   01;31
.Z   01;31
.gz  01;31
.jpg 01;35 # image formats
.gif 01;35
.bmp 01;35
.xbm 01;35
.xpm 01;35
.tif 01;35

Samba

More info: http://blog.qnology.com/2013/03/tutorial-pogoplug-e02-with-arch-linux.html

pacman -Sy samba
cd /etc/samba
wget http://dl.dropbox.com/u/42238/pogoplug/v2/smb.conf
nano /etc/samba/smb.conf
[global]
 workgroup = MIN_LAN
 server string = OCELL
 netbios name = OCELL
 load printers = no
 printing = bsd
 printcap name = /dev/null
 disable spoolss = yes
 log file = /var/log/samba/%m.log
 max log size = 50
 socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE
 write cache size = 2097152
 use sendfile = yes

 #unprotected/public share without login
 security = user
 map to guest = Bad User
 guest account = root

#[root$]
#  path = /
#  read only = no
#  public = yes
#  writable = yes
#  #force user = root
#  guest ok = yes

[usb]
  path = /media
  read only = no
  public = yes
  writable = yes
  #force user = root
  guest ok = yes
systemctl start smbd nmbd
systemctl enable smbd nmbd

No se si cal:

systemctl enable samba
groupadd samba

....


REinstall my.pogoplug.com service

http://archlinuxarm.org/forum/viewtopic.php?t=3343

Backup of the URL:

Updated: May 28 2013
- Changed location of hbplug.conf (now it's copied to /usr/local/cloudengines/ and not /usr/local/cloudengines/bin)
- I found no reliable way to generate the service id, so now on you have to do it manually. There's no default /etc/pogoplug.conf

Install with:
CODE: SELECT ALL
pacman -U http://dl.dropboxusercontent.com/u/15043728/ArchLinuxArm/pogoplug-3.3.0-5-arm.pkg.tar.xz


Getting service ID and a proper CRYPTO KEY:
There are several ways to do this, I'll explain one here:

If you are copying the svcid from the bottom of the device skip this step.
1. Run 
CODE: SELECT ALL
/usr/local/cloudengines/bin/hbplug | grep "Device ID"

and take note of the shown Device ID. We are interested in this line, particularly the string in red 
[060343.931][MAIN ][HBPLUG][08] Device ID: 8C3CUTEY6MNGHLCV9FYVUNEZCN
2. Edit /usr/local/cloudengines/bin/hbplug.conf and add your svcid, either the one that you noted above, or the one from the bottom of the device:
CODE: SELECT ALL
nano /usr/local/cloudengines/bin/hbplug.conf

the line "svcid=" should now be "svcid=8C3CUTEY6MNGHLCV9FYVUNEZCN"
3. Now run
CODE: SELECT ALL
/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
several times until it reads CRYPTO KEY: VALID
Wait a reasonable amount of time before CTRL+C'ing it (60 sec?)
If after 5 runs it doesn't work, reboot and do the same thing until it works. It will eventually.
4. Now you should be set, just move the hbplug.conf to /etc as pogoplug.conf
CODE: SELECT ALL
mv /usr/local/cloudengines/bin/hbplug.conf /etc/pogoplug.conf

Now you can edit /etc/pogoplug.conf to include the directories that you want to be visible by the my.pogoplug.com service

A couple of points:
- config file location /etc/pogoplug.conf --> EDIT IT to get directories visible at my.pogoplug.com
- Format: vfsdir<number>=<name>,<path>
- Example: vfsdir0=plugdata,/media/2TBDrive/Downloads
- Don't change order of variables. Add more directories under each other. E.g Line1: vfsdir0=.. Line2: vfsdir1=..
- includes pogoplug.service for systemd and pogoplug initscript for sysv

Don't forget to (re)register your device at my.pogoplug.com. 


Steps followed:


pacman -U http://dl.dropboxusercontent.com/u/15043728/ArchLinuxArm/pogoplug-3.3.0-5-arm.pkg.tar.xz
nano /usr/local/cloudengines/hbplug.conf

edit

installdir=/usr/local/cloudengines
datadir=./T3000_64k_Backup_U/
vfsdir0=PogoPlug_USB,/media
nohotplug=1
svcid=53UFGEBGD77LEYKX73YFCM6XPW

ocell2

3WQMBM9WNJ32H25LKGWHDDCDP6
/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
/usr/local/cloudengines/bin/hbplug | grep "CRYPTO"
mv /usr/local/cloudengines/hbplug.conf /etc/pogoplug.conf
systemctl enable pogoplug

Update Kernel

Optional (Not sure if it's needed).

http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/

Backup of the URL above:

8. Update Kernel to >3.2
Warning: This specific instruction works for PogoplugV2 only!
You can brick your device!

The current kernel for PogoplugV2 is 3.1.x but 3.8.x or newer is available.
You have to update manually because newer kernels need a new uboot.

You need the newest uboot to boot Kernels >3.2 so you have to install it before:
If this is a fresh installation you probably have the newest uboot already and you don’t have to do that!


cd /tmp
wget http://jeff.doozan.com/debian/uboot/install_uboot_mtd0.sh
chmod +x install_uboot_mtd0.sh
./install_uboot_mtd0.sh
Then you have to correct your arcNumber and matchid if you didn’t follow “Blink LED to HDD activity”.


pacman -Sy uboot-env
fw_setenv arcNumber 3542
fw_setenv machid dd6
reboot
Now you can install the new Kernel files with:


pacman -Sy linux-kirkwood linux-headers-kirkwood
reboot


Keep dynamic DNS updated from dyndns.org

pacman -S ddclient
vim /etc/ddclient/ddclient.conf
# Basic HTTPS configuration file for ddclient
#
# /etc/ddclient.conf
daemon=600
pid=/var/run/ddclient.pid
ssl=yes
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
login=your-username
password=your-password
protocol=dyndns2
server=members.dyndns.org
wildcard=YES
example.dyndns.info
#custom=yes, example.com

More info: http://dyn.com/support/clients/linux/ddclient/





Disable some logging to extend USB stick lifetime

Info from: http://obihoernchen.net/wordpress/770/plug_computer_arch_linux/


Flash drives have limited number of write cycles and default linux logging will write pretty much so your USB will be destroyed pretty fast.

That’s why a swap file on your USB stick is a really bad idea!

But you can disable some logging to extend the liefetime of your USB stick.


Just edit syslog-ng.conf and disable some of the “log { source(src); filter…” lines at the end of the file.

You can comment out (add a “#” in front of the line) all lines if you want to disable everything.


nano /etc/syslog-ng/syslog-ng.conf I’ve disabled some of them. That’s my example:

# Disable some logging
#log { source(src); filter(f_acpid); destination(d_acpid); };
log { source(src); filter(f_authpriv); destination(d_authlog); };
#log { source(src); filter(f_syslog); destination(d_syslog); };
#log { source(src); filter(f_cron); destination(d_cron); };
#log { source(src); filter(f_daemon); destination(d_daemon); };
#log { source(src); filter(f_kernel); destination(d_kernel); };
#log { source(src); filter(f_lpr); destination(d_lpr); };
#log { source(src); filter(f_mail); destination(d_mail); };
#log { source(src); filter(f_news); destination(d_news); };
#log { source(src); filter(f_ppp); destination(d_ppp); };
log { source(src); filter(f_user); destination(d_user); };
#log { source(src); filter(f_uucp); destination(d_uucp); };
#log { source(src); filter(f_debug); destination(d_debug); };
#log { source(src); filter(f_messages); destination(d_messages); };
log { source(src); filter(f_err); destination(d_errors); };
log { source(src); filter(f_emergency); destination(d_console); };
#log { source(src); filter(f_everything); destination(d_everything); };
#log { source(src); filter(f_iptables); destination(d_iptables); };

On top of that you could disable logging of some servers like samba, minidlna and so on.

I don’t do that because I want to have these logs but to do so set the log path in the config files to /dev/null


Disable System Journal

Info: http://forums.fedoraforum.org/showthread.php?t=292543

It write a lot of data to

/var/log/journal/

Simply disabling a service isn't always enough, and now, I don't know why. To tell systemd that you really don't want it starting at boot, run this as root:

systemctl mask systemd-journald.service

You should see a response telling you that the service has been linked to /dev/null, which will make sure that it doesn't start at boot until you reverse the process by using unmask instead of mask.



BitTorrent Sync (BTsync)

Info from: http://blog.qnology.com/2013/03/tutorial-pogoplug-e02-with-arch-linux.html

BitTorrent Sync is a free utility that uses the bittorrent protocol to keep folders in sync across devices. It can be used with OS X, Windows, Android and Linux.

  1. create folder
mkdir -p /usr/local/bin
cd /usr/local/bin
  1. download and untar
wget http://btsync.s3-website-us-east-1.amazonaws.com/btsync_arm.tar.gz
tar -xzvf btsync_arm.tar.gz
  1. delete unneeded files
rm LICENSE.TXT btsync_arm.tar.gz
  1. download service file
cd /etc/systemd/system
wget http://dl.dropbox.com/u/42238/pogoplug/v2/btsync.service


/etc/systemd/system/btsync.service

[Unit]
Description=BitTorrent Sync
After=network.target

[Service]
ExecStartPre=/bin/sh -c 'echo 2 > /proc/cpu/alignment'
ExecStart=/usr/local/bin/btsync --config /etc/btsync/btsync.json
Restart=always
Type=forking

[Install]
WantedBy=multi-user.target



/etc/btsync/btsync.json

{
  "device_name": "My Sync Device",
  "listening_port" : 4523,                       // 0 - randomize port

/* storage_path dir contains auxilliary app files
   if no storage_path field: .sync dir created in the directory
   where binary is located.
   otherwise user-defined directory will be used
*/
  "storage_path" : "/root/btsync",    // "/home/user/.sync",

// uncomment next line if you want to set location of pid file
// "pid_file" : "/var/run/btsync/btsync.pid",


  "check_for_updates" : true,
  "use_upnp" : false,                              // use UPnP for port mapping


/* limits in kB/s
   0 - no limit
*/
  "download_limit" : 0,
  "upload_limit" : 0,

/* remove "listen" field to disable WebUI
   remove "login" and "password" fields to disable credentials check
*/
  "webui" :
  {
    "listen" : "0.0.0.0:8888",
    "login" : "XXXX",
    "password" : "XXXX"
  },

/* !!! if you set shared folders in config file WebUI will be DISABLED !!!
   shared directories specified in config file
   override the folders previously added from WebUI.
*/
/*
  ,
  "shared_folders" :
  [
    {
//  use --generate-secret in command line to create new secret
      "secret" : "MY_SECRET_1",                   // * required field
      "dir" : "/home/user/bittorrent/sync_test", // * required field

//  use relay server when direct connection fails
      "use_relay_server" : true,
      "use_tracker" : true,
      "use_dht" : false,
      "search_lan" : true,
//  enable SyncArchive to store files deleted on remote devices
      "use_sync_trash" : true,
//  specify hosts to attempt connection without additional search
      "known_hosts" :
      [
        "192.168.1.2:44444"
      ]
    }
  ]
*/

// Advanced preferences can be added to config file.
// Info is available in BitTorrent Sync User Guide.




"folder_rescan_interval": 86400,   // 600
"sync_trash_ttl": 0



}



  1. start btsync
systemctl start btsync
  1. autostart btsync on reboot
systemctl enable btsync


  1. http://pogoplug:8888/gui


DNSmasq

Dnsmasq is a lightweight, easy to configure DNS forwarder. Dnsmasq accepts DNS queries and either answers them from a small, local cache or forwards them to a real, recursive DNS server. It loads the contents of /etc/hosts, so that local host names which do not appear in the global DNS can be resolved

pacman -S dnsmasq
systemctl start dnsmasq
systemctl enable dnsmasq

Add your hosts here:

vi /etc/hosts

To use the tool dig install:

pacman -S dnsutils

Optionally modify your /etc/resolv.conf

nameserver 127.0.0.1


IPtables

To filter SAMBA accessing from internet:

iptables -A INPUT -s 192.168.0.0/16 -p udp --dport 137 -j ACCEPT
iptables -A INPUT -s 192.168.0.0/16 -p udp --dport 138 -j ACCEPT
iptables -A INPUT -s 192.168.0.0/16 -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -s 192.168.0.0/16 -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -p udp --dport 137 -j DROP
iptables -A INPUT -p udp --dport 138 -j DROP
iptables -A INPUT -p tcp --dport 139 -j DROP
iptables -A INPUT -p tcp --dport 445 -j DROP
systemctl enable iptables
systemctl start iptables
iptables-save > /etc/iptables/iptables.rules


You can also add to /etc/samba/smb.conf

# bloqueja access des de internet:
hosts allow = 192.168.0.0/16 10.0.0.0/16 127.0.0.1
hosts deny = 0.0.0.0/0


Speed up SSH /SFTP

Faster than Samba, you can mount a drive via SSHFS, also on windows using https://code.google.com/p/win-sshfs/

To avoid using 3des-cbc which is very slow,add the following to /etc/ssh/sshd_config

#trec el 3des-cbc que necessita molt de processador i fa que les transferencies siguin a 2MB/s enlloc de 5MB/s
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour