Projet

Général

Profil

Paste
Télécharger (2,17 ko) Statistiques
| Branche: | Révision:

root / other-scripts / d7-sync-config.example.sh @ f6a5e032

1 3e00cc24 Julien Enselme
# Example file for d7-sync.sh.  Adapt to your own needs in d7-sync-config.sh
2
3
DIR_MULTIASSOS=/home/jenselme/Documents/assos/drupal
4
DIR_DRUPAL7=$DIR_MULTIASSOS/drupal7
5
DIR_DRUPAL7_SITES=$DIR_DRUPAL7/sites
6 0ddd66a7 Julien Enselme
SITES_PHP=$DIR_DRUPAL7_SITES/sites.php
7 3e00cc24 Julien Enselme
LOCAL_BRANCH_NAME=local
8
DOMAIN=assos.local
9 f6a5e032 Julien Enselme
# Connexion variable
10
REMOTE_DIR_TMP_SAS="~/tmp/assos"
11
SSH_ID_SAS=jenselme
12
SSH_ID_WEBASSOS=assos@webassos.ec-m.fr
13
14
## Functions
15
# We cannot directly use commands like scp or rsync since we cannot directly access
16
# the server. We use the functions defined below instead. It is advised to put these
17
# functions in your .bashrc or equivalent in order to use them any time you want. These
18
# functions are tested and work with bash. They are incompatible witsh zsh.
19
# They can only take 2 positional parameters.
20
21
copy_assos_init() {
22
    ssh $SSH_ID_SAS "mkdir -p $REMOTE_DIR_TMP_SAS"
23
}
24
25
get_args() {
26
    if [ "$#" -gt 2 ] ; then
27
	echo ${@:1:$#-2}
28
    fi
29
}
30
31
clean() {
32
    ssh $SSH_ID_SAS "rm -r $REMOTE_DIR_TMP_SAS/$1"
33
}
34
35
scp_from_assos() {
36
    local input=("$@")
37
    local args=$(get_args $@)
38
    local source=${input[$#-2]}
39
    local dest=${input[$#-1]}
40
41
    ssh $SSH_ID_SAS "scp $args $SSH_ID_WEBASSOS:$source $REMOTE_DIR_TMP_SAS" &&
42
    scp $args $SSH_ID_SAS:$REMOTE_DIR_TMP_SAS/$source $dest &&
43
    clean $source
44
}
45
46
scp_to_assos() {
47
    local input=("$@")
48
    local args=$(get_args $@)
49
    local source=${input[$#-2]}
50
    local dest=${input[$#-1]}
51
52
    scp $args $source $SSH_ID_SAS:$REMOTE_DIR_TMP_SAS/$source &&
53
    ssh $SSH_ID_SAS "scp $args $REMOTE_DIR_TMP_SAS/$source $SSH_ID_WEBASSOS:$dest" &&
54
    clean $source
55
}
56
57
rsync_from_assos() {
58
    local input=("$@")
59
    local args=$(get_args $@)
60
    local source=${input[$#-2]}
61
    local dest=${input[$#-1]}
62
63
    ssh $SSH_ID_SAS "rsync $args $SSH_ID_WEBASSOS:$source $REMOTE_DIR_TMP_SAS" &&
64
    rsync $args $SSH_ID_SAS:$REMOTE_DIR_TMP_SAS/$source $dest &&
65
    clean $source
66
}
67
68
rsync_to_assos() {
69
    local input=("$@")
70
    local args=$(get_args $@)
71
    local source=${input[$#-2]}
72
    local dest=${input[$#-1]}
73
74
    rsync $args $source $SSH_ID_SAS:$REMOTE_DIR_TMP_SAS/$source &&
75
    ssh $SSH_ID_SAS "rsync $args $REMOTE_DIR_TMP_SAS/$source $SSH_ID_WEBASSOS:$dest" &&
76
    clean $source
77
}