-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_resources
executable file
·140 lines (120 loc) · 5.28 KB
/
update_resources
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env bash
set -e
# Resouce list for javascript dependencies.
JAVASCRIPT=$(cat <<'EOF'
auto-entities.js https://raw.githubusercontent.com/thomasloven/lovelace-auto-entities/master/auto-entities.js
mini-graph-card-bundle.js https://github.com/kalkih/mini-graph-card/releases/latest/download/mini-graph-card-bundle.js
mini-media-player-bundle.js https://github.com/kalkih/mini-media-player/releases/latest/download/mini-media-player-bundle.js
mushroom.js https://github.com/piitaya/lovelace-mushroom/releases/latest/download/mushroom.js
swipe-navigation.js https://github.com/zanna-37/hass-swipe-navigation/releases/latest/download/swipe-navigation.js
vertical-stack-in-card.js https://raw.githubusercontent.com/ofekashery/vertical-stack-in-card/master/vertical-stack-in-card.js
EOF
)
# Resouce list for theme dependencies.
THEMES=$(cat <<'EOF'
google_theme.yaml https://raw.githubusercontent.com/JuanMTech/google-theme/main/themes/google_theme.yaml
mushroom-shadow.yaml https://raw.githubusercontent.com/piitaya/lovelace-mushroom-themes/main/themes/mushroom-shadow.yaml
mushroom-square-shadow.yaml https://raw.githubusercontent.com/piitaya/lovelace-mushroom-themes/main/themes/mushroom-square-shadow.yaml
mushroom-square.yaml https://raw.githubusercontent.com/piitaya/lovelace-mushroom-themes/main/themes/mushroom-square.yaml
mushroom.yaml https://raw.githubusercontent.com/piitaya/lovelace-mushroom-themes/main/themes/mushroom.yaml
EOF
)
# Resouce list for custom components.
CUSTOM_COMPONENTS=$(cat <<'EOF'
custom_components/afvalbeheer https://github.com/pippyn/Home-Assistant-Sensor-Afvalbeheer
custom_components/alarmo https://github.com/nielsfaber/alarmo
custom_components/blitzortung https://github.com/mrk-its/homeassistant-blitzortung
custom_components/car_wash https://github.com/Limych/ha-car_wash
custom_components/eufy_security https://github.com/fuatakgun/eufy_security
custom_components/flightradar24 https://github.com/AlexandrErohin/home-assistant-flightradar24
custom_components/bambu_lab https://github.com/greghesp/ha-bambulab
custom_components/home_connect_alt https://github.com/ekutner/home-connect-hass
custom_components/ical https://github.com/tybritten/ical-sensor-homeassistant
custom_components/kamstrup_403 https://github.com/golles/ha-kamstrup_403
custom_components/knmi https://github.com/golles/ha-knmi
custom_components/lghorizon https://github.com/Sholofly/lghorizon
custom_components/media_player_template https://github.com/Sennevds/media_player.template
custom_components/p2000 https://github.com/cyberjunky/home-assistant-p2000
custom_components/spook https://github.com/frenck/spook
custom_components/webrtc https://github.com/AlexxIT/WebRTC
custom_components/xiaomi_miio_fan https://github.com/syssi/xiaomi_fan
EOF
)
update_resources () {
# $1 = Resource list.
# $2 = Folder.
echo "$1" | while IFS= read -r line ; do
RESOUCRE=${line% *}
REMOTE_FILE=${line#* }
curl -sL $REMOTE_FILE --output $2/$RESOUCRE
done
git status $2
}
update_javascript () {
update_resources "$JAVASCRIPT" www
}
update_themes () {
update_resources "$THEMES" themes
}
update_custom_components () {
cd external
for dir in ./*
do
if [ -d "${dir}" ]
then
cd ${dir}
BRANCH=$( git branch --show )
pwd
echo "On branch: ${BRANCH}, updating..."
git pull
echo ""
cd ../
fi
done
}
update_all () {
echo "Updating javascript"
update_javascript
echo -e "\nUpdating themes"
update_themes
echo -e "\nUpdating custom components"
update_custom_components
}
init_custom_components () {
mkdir -p external
mkdir -p custom_components
echo "$CUSTOM_COMPONENTS" | while IFS= read -r line ; do
COMPONENT=${line% *}
REPO=${line##* }
FOLDER=${REPO##*/}
NAME=${COMPONENT##*/}
if [ ! -d "external/${FOLDER}" ]
then
cd external
git clone ${REPO}
cd ../custom_components
ln -s ../external/${FOLDER}/${COMPONENT} ${NAME}
cd ../
fi
done
}
usage () {
echo "This program requires 1 argument, eg."
echo " all - Update all resources"
echo " custom_components - Update all custom components"
echo " javascript - Update all javascript resources"
echo " js - Update all javascript resources"
echo " themes - Update all theme resources"
echo " init_custom_components - Initialize all custom components"
}
# Make the parent dir, the working directory.
cd "$(dirname "$0")/.."
# $1 = User input, what to update.
case $1 in
all) update_all ;;
javascript|js) update_javascript ;;
themes) update_themes ;;
custom_components) update_custom_components ;;
init_custom_components) init_custom_components ;;
*) echo "Bad input"; usage; exit 1 ;;
esac