source: lliurex-up/trunk/fuentes/scripts/common/change-sources-list @ 2609

Last change on this file since 2609 was 2609, checked in by kbut, 4 years ago

refactoring

File size: 1.7 KB
Line 
1#!/bin/sh
2# SourcesList evolutor
3
4# gettext domain
5TEXTDOMAIN="lliurex-up"
6export TEXTDOMAIN
7
8COMMON_LIBRARY="/usr/share/lliurex-up/common-upgrade-vars.sh"
9if [  -r $COMMON_LIBRARY  ] ; then 
10        . $COMMON_LIBRARY
11fi
12
13#gettext messages
14INFO_MESSAGE="$(gettext "Change the software origins")"
15BACKUP_SOURCES_LIST="$(gettext "Making a backup of sources.list file on /etc/apt/sources.list.backup-lliurex-up")"
16CHANGED_SOURCES_LIST_MESSAGE="$(gettext "Software origins updated")"
17
18# Methods
19_info()
20{
21        echo "$INFO_MESSAGE"
22}
23
24_migrate()
25{
26        # Test upgrade version if is a server
27        vc=0
28        lliurex-version -n | grep -q 13.06 || vc=1
29        if [ $vc -eq 0 ]; then
30                if [ -x /usr/sbin/platinum-upgrade ]; then
31                        /usr/sbin/platinum-upgrade || true
32                fi
33        fi
34
35        # Backup sources list
36        echo "$CHANGED_SOURCES_LIST_MESSAGE"
37        cp  -f $SOURCES_LIST_PATH $BACKUP_SOURCES_LIST_PATH
38       
39        # Change values
40        sed -i "s%$OLD_GENERATION_PATTERN%$NEXT_GENERATION_PATTERN%g;s%$OLD_CODENAME%$NEXT_CODENAME%g" $SOURCES_LIST_PATH
41     
42        # Added source.list client
43        rc=0
44        lliurex-version -t client || rc=1
45        if [ $rc -eq 0 ] ; then
46                sed -i "s%$OLD_GENERATION%$NEXT_GENERATION%g;s%$OLD_CODENAME%$NEXT_CODENAME%g" $SOURCES_LIST_PATH
47        fi
48       
49        #echo "# Added by LliureX UP #" >> "$SOURCES_LIST_PATH"
50        #echo "$SOURCES_LIST_OK" >> "$SOURCES_LIST_PATH"
51        #echo "# Added by LliureX UP #" >> "$SOURCES_LIST_PATH"
52
53        [ ! -f /etc/apt/preferences.d/lsb_lliurex_pinning ] || rm -f /etc/apt/preferences.d/lsb_lliurex_pinning 
54        echo "$CHANGED_SOURCES_LIST_MESSAGE"
55}
56
57_usage()
58{
59        echo " * [ LliureX Up ] :  # Unknown argument"
60}
61
62_die()
63{
64        echo " * [ LliureX Up ] : Error: $1"
65        exit 1
66}
67
68ACTION="$1"
69case "$ACTION" in
70        migrate)
71                _migrate
72        ;;
73        info)
74                _info
75        ;;
76        *)
77                _usage
78        ;;
79esac
80
81exit 0
Note: See TracBrowser for help on using the repository browser.