-
Notifications
You must be signed in to change notification settings - Fork 13
/
install.sh
executable file
·51 lines (38 loc) · 1.45 KB
/
install.sh
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
#!/bin/bash
set -e;
PUBKEY_REPO="https://github.com/AOSC-Dev/dev-pubkeys.git";
BRANCH="master";
LOCAL_DIR="pubkeys";
SCRIPT_INSTALL_DIR="$HOME/.update_pubkeys"
pushd /tmp;
if [ -d $LOCAL_DIR ]; then
rm -Rf $LOCAL_DIR;
fi
echo ">>> Downloading scripts...";
git clone $PUBKEY_REPO -b $BRANCH $LOCAL_DIR;
pushd $LOCAL_DIR;
echo ">>> Copying files...";
if [ -d $SCRIPT_INSTALL_DIR ]; then
rm -Rf $SCRIPT_INSTALL_DIR;
mkdir -p $SCRIPT_INSTALL_DIR;
else
mkdir -p $SCRIPT_INSTALL_DIR;
fi
cp script/update.sh $SCRIPT_INSTALL_DIR/update.sh;
echo ">>> Copying systemd files... (requires sudo)";
sed -i "s|User=aosc|User=$USER|g" systemd/update_pubkeys.service;
sed -i "s|Environment=\"HOME=/home/aosc\"|Environment=\"HOME=$HOME\"|g" systemd/update_pubkeys.service;
sed -i "s|WorkingDirectory=/home/aosc/.update_pubkeys|WorkingDirectory=$SCRIPT_INSTALL_DIR|g" systemd/update_pubkeys.service;
sed -i "s|ExecStart=/home/aosc/.update_pubkeys/update.sh|ExecStart=$SCRIPT_INSTALL_DIR/update.sh|g" systemd/update_pubkeys.service;
sudo cp systemd/update_pubkeys.service /etc/systemd/system/update_pubkeys_$USER.service;
sudo cp systemd/update_pubkeys.timer /etc/systemd/system/update_pubkeys_$USER.timer
sudo systemctl daemon-reload;
sudo systemctl start update_pubkeys_$USER --now;
echo ">>> Enabling timer..."
sudo systemctl enable update_pubkeys_$USER.timer;
sudo systemctl start update_pubkeys_$USER.timer;
echo ">>> Cleaning up..."
popd;
rm -Rf $LOCAL_DIR;
popd;
echo ">>> Done."