install: reset mirror configuration if not in china

pull/454/head
undefined 2 years ago
parent 3f14d7a63e
commit d1a652d364

@ -15,7 +15,7 @@ To disable this feature, checkout our sourcecode."
mkdir -p /data/db /data/file ~/.hydro mkdir -p /data/db /data/file ~/.hydro
bash <(curl https://hydro.ac/nix.sh) bash <(curl https://hydro.ac/nix.sh)
export PATH=$HOME/.nix-profile/bin:$PATH export PATH=$HOME/.nix-profile/bin:$PATH
nix-env -iA nixpkgs.nodejs nixpkgs.pm2 nixpkgs.yarn nixpkgs.esbuild nixpkgs.coreutils nixpkgs.bash nixpkgs.unzip nixpkgs.zip nixpkgs.diffutils nixpkgs.qrencode nix-env -iA nixpkgs.nodejs nixpkgs.coreutils nixpkgs.qrencode
echo "扫码加入QQ群" echo "扫码加入QQ群"
echo https://qm.qq.com/cgi-bin/qm/qr\?k\=0aTZfDKURRhPBZVpTYBohYG6P6sxABTw | qrencode -o - -m 2 -t UTF8 echo https://qm.qq.com/cgi-bin/qm/qr\?k\=0aTZfDKURRhPBZVpTYBohYG6P6sxABTw | qrencode -o - -m 2 -t UTF8
echo "// File created by Hydro install script\n" >/tmp/install.js echo "// File created by Hydro install script\n" >/tmp/install.js

@ -183,6 +183,17 @@ const Steps = () => [
{ {
init: 'install.preparing', init: 'install.preparing',
operations: [ operations: [
() => {
if (CN) return;
// rollback mirrors
writeFileSync('/etc/nix/nix.conf', `substituters = https://cache.nixos.org/ https://nix.hydro.ac/cache
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydro.ac:EytfvyReWHFwhY9MCGimCIn46KQNfmv9y8E2NqlNfxQ=
connect-timeout = 10`);
exec('nix-channel --del nixpkgs', { stdio: 'inherit' });
exec('nix-channel --add nixpkgs https://nixos.org/channels/nixpkgs-unstable', { stdio: 'inherit' });
exec('nix-channel --update', { stdio: 'inherit' });
},
'nix-env -iA nixpkgs.pm2 nixpkgs.yarn nixpkgs.esbuild nixpkgs.bash nixpkgs.unzip nixpkgs.zip nixpkgs.diffutils',
() => { () => {
// Not implemented yet // Not implemented yet
// if (fs.existsSync('/home/judge/src')) { // if (fs.existsSync('/home/judge/src')) {
@ -234,12 +245,12 @@ const Steps = () => [
() => { () => {
if (!CN) return; if (!CN) return;
try { try {
exec('yarn config set registry https://registry.npmmirror.com/'); exec('yarn config set registry https://registry.npmmirror.com/', { stdio: 'inherit' });
exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge'); exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge', { stdio: 'inherit' });
} catch (e) { } catch (e) {
console.log('Failed to install from npmmirror, fallback to yarnpkg'); console.log('Failed to install from npmmirror, fallback to yarnpkg');
} finally { } finally {
exec('yarn config set registry https://registry.yarnpkg.com'); exec('yarn config set registry https://registry.yarnpkg.com', { stdio: 'inherit' });
} }
try { try {
exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge'); exec('yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge');
@ -353,7 +364,6 @@ async function main() {
console.error(e); console.error(e);
console.log('Cannot find the best mirror. Fallback to default.'); console.log('Cannot find the best mirror. Fallback to default.');
} }
return;
const steps = Steps(); const steps = Steps();
for (let i = 0; i < steps.length; i++) { for (let i = 0; i < steps.length; i++) {
const step = steps[i]; const step = steps[i];

Loading…
Cancel
Save